This commit is contained in:
JUNGGWAN KIM 2024-09-23 18:06:04 +09:00
parent 798c6ce27f
commit 248e0ada31
2 changed files with 28 additions and 11 deletions

View File

@ -2,31 +2,44 @@ package rasel.lunar.launcher.model
import android.app.appsearch.StorageInfo
import com.google.gson.annotations.SerializedName
import io.realm.kotlin.ext.realmListOf
import io.realm.kotlin.types.RealmList
import io.realm.kotlin.types.RealmObject
data class WeatherInfo (
@SerializedName("coord")
var coord: Location? = null,
class WeatherInfo : RealmObject {
constructor()
constructor(coord: Location?, weather: Array<Weather>?, main: Main?) {
this.coord = coord
weather?.let {
this.weather?.addAll(it)
}
@SerializedName("weather")
var weather: Array<Weather>? = null,
this.main = main
}
@SerializedName("main")
var main: Main? = null
)
@SerializedName("coord")
var coord: Location? = null
class Location {
@SerializedName("weather")
var weather: RealmList<Weather>? = realmListOf()
@SerializedName("main")
var main: Main? = null
}
class Location : RealmObject {
var lon: String? = null
var lat: String? = null
}
class Weather {
class Weather : RealmObject{
var id: String? = null
var main: String? = null
var description: String? = null
var icon: String? = null
}
class Main {
class Main : RealmObject {
var temp: String? = null
var feels_like: String? = null
var temp_min: String? = null

View File

@ -9,6 +9,7 @@ import com.google.android.gms.location.Priority
import com.google.android.gms.tasks.CancellationTokenSource
import io.realm.kotlin.Realm
import io.realm.kotlin.RealmConfiguration
import io.realm.kotlin.UpdatePolicy
import io.realm.kotlin.types.TypedRealmObject
import rasel.lunar.launcher.model.WeatherInfo
import rasel.lunar.launcher.utils.BLog
@ -82,6 +83,9 @@ class OpenWeatherGetter : BaseGetter {
// 받아온 결과를 메모리에 올려놓고 처리할 클래스가 필요해
response.body()?.let {w->
BLog.LOGE("Location error >>> ${w.coord}}")
WorkersDb.getRealm().writeBlocking {
copyToRealm(w, UpdatePolicy.ALL)
}
}