openWeather(api), retrofilt2
This commit is contained in:
parent
809b2b4279
commit
b298c6d86f
@ -3,16 +3,16 @@ package rasel.lunar.launcher.model
|
||||
import android.app.appsearch.StorageInfo
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
class WeatherInfo {
|
||||
data class WeatherInfo (
|
||||
@SerializedName("coord")
|
||||
private var coord: Location? = null
|
||||
var coord: Location? = null,
|
||||
|
||||
@SerializedName("weather")
|
||||
private var weather: Weather? = null
|
||||
var weather: Array<Weather>? = null,
|
||||
|
||||
@SerializedName("main")
|
||||
private var main: Main? = null
|
||||
}
|
||||
var main: Main? = null
|
||||
)
|
||||
|
||||
class Location {
|
||||
var lon: String? = null
|
||||
|
||||
@ -65,26 +65,25 @@ class OpenWeatherGetter : BaseGetter {
|
||||
|
||||
val service = retro.create<RestrofitService>()
|
||||
|
||||
val call = service.getPosts("lat=44.34&lon=10.99&appid=87cd0810b7e4b4debd31a6ef98b98154")
|
||||
val call = service.getPosts()
|
||||
|
||||
call!!.enqueue(object: Callback<WeatherInfo>() {
|
||||
override fun onResponse(
|
||||
call: Call<WeatherInfo>,
|
||||
response: Response<WeatherInfo>
|
||||
) {
|
||||
BLog.LOGE("Location >>> ")
|
||||
call?.enqueue(object: Callback<WeatherInfo?> {
|
||||
override fun onResponse(call: Call<WeatherInfo?>, response: Response<WeatherInfo?>) {
|
||||
BLog.LOGE("Location error >>> $response")
|
||||
BLog.LOGE("Location error >>> ${WeatherInfo().toString()}")
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<WeatherInfo>, t: Throwable) {
|
||||
BLog.LOGE("Location >>> ")
|
||||
override fun onFailure(call: Call<WeatherInfo?>, t: Throwable) {
|
||||
BLog.LOGE("Location error >>> $t")
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
interface RestrofitService {
|
||||
@GET("/data/2.5/weather?{post}}")
|
||||
fun getPosts(@Path("post") post: String?): Call<WeatherInfo?>?
|
||||
@GET("/data/2.5/weather?lat=44.34&lon=10.99&appid=87cd0810b7e4b4debd31a6ef98b98154")
|
||||
fun getPosts(): Call<WeatherInfo?>?
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user