Tag: android architecture

没有调用Android的LiveData.addSource onChanged事件

我正在使用Android Archi + Retrofit + RxAndroid在Kotlin。 我需要从服务器获取响应时更新我的​​数据对象。 但是livedata.addSource的onChanged没有调用。 我从Git代码获取帮助: – https://github.com/shahbazahmed1269/AndroidGithubIssues 这是我在Kotlin的代码: class LoginRepository : BaseRepository() { fun callLoginApi(data: HashMap): LiveData { val liveData: MutableLiveData = MutableLiveData() // val call = mApiService.getLoginUser(data) mApiService.getLoginUser(data) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( { user -> liveData.value = user Log.e(“response”, user.toString()) }, { error -> liveData.value = LoginResponse(error = error.localizedMessage) Log.e(“Error”, error.message) […]