我现在回国了liveDataName,但我也想回国liveDataImage。
fun getProfileInfo(): LiveData<String> {
val call: Call<UserProfile>? = NetworkService.getInstance()
.jsonApi
.getProfile()
call?.enqueue(object : Callback<UserProfile>{
override fun onResponse(call: Call<UserProfile>, response: Response<UserProfile>) {
if (response.isSuccessful) {
response.body()?.let {
liveDataName.value = it.username
liveDataImage.value = it.defaultAvatar
}
}
}
override fun onFailure(call: Call<UserProfile>, t: Throwable) {}
})
return liveDataName
}
Run Code Online (Sandbox Code Playgroud)