问题:
如题描述。
解决办法:
参见一下注释掉的代码
com\fuckweather\android\ui\weather\WeatherViewModel.kt
package com.fuckweather.android.ui.weather
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.fuckweather.android.logic.Repository
import com.fuckweather.android.logic.model.Location
//import android.location.Location
class WeatherViewModel : ViewModel() {
private val locationLiveData = MutableLiveData<Location>()
var locationLng = ""
var locationLat = ""
var placeName = ""
val weatherLiveData = Transformations.switchMap(locationLiveData) { location ->
// Repository.refreshWeather(location.lng, location.lat)
Repository.refreshWeather(location.lng, location.lat, placeName)
}
fun refreshWeather(lng: String, lat: String) {
locationLiveData.value = Location(lng, lat)
}
}
com\fuckweather\android\logic\Repository.kt
// fun refreshWeather(lng: String, lat: String) = fire(Dispatchers.IO) {
fun refreshWeather(lng: String, lat: String, placeName: String) = fire(Dispatchers.IO) {