Questions tagged [mutablelivedata]

LiveData which publicly exposes setValue(T) and postValue(T) method.

320 questions
0
votes
1 answer

Having trouble in observing a liveData list in my viewModel?

I am displaying markers from my database on my map, But i have a filter for the user from where he can adjust the time and the markers will show in that time. I want to observe the list that is updated each time when the user changes the time…
0
votes
0 answers

How to fix "Cannot find symbol xxx.xxxBindingImple"

I had an error while working with ViewModel in Kotlin. HCJob.kt class HCJob { private lateinit var jobImgURL: String private lateinit var jobTitle: String private lateinit var jobLocation: String // Constructor // Getters *…
0
votes
1 answer

Quick question about MutableLiveData (android)

Inside main activity, i cannot call getValue() on a MutableLiveData attribute of a ViewModel; however, i can inside the ViewModel class. What is the reason for this? Example code: Main Activity - noodleViewModel =…
0
votes
2 answers

LiveData not updating after changed using Handler PostDelayed?

Here's my ViewModel class MainViewModel(repository: MainActivityRepo) : ViewModel() { val isLoading: MutableLiveData = MutableLiveData() init { isLoading.value = false android.os.Handler().postDelayed({ isLoading.value =…
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
0
votes
1 answer

Publish multiple result from LiveDataReactiveStreams.fromPublisher() inside RxJava nested chain

Let's start with a basic sample, Suppose I have the follow code block for getting an Auth Token from the Repository private fun getToken(): LiveData { return LiveDataReactiveStreams.fromPublisher(remoteSource.getAuthToken() …
0
votes
2 answers

Android Two Way Databinding working only one way

I have ViewModel: class MyViewModel : ViewModel(){ private val _user = MutableLiveData("") val user: LiveData = _user fun onBtnClick(){ Log.i("MyViewModel", "user: ${_user.value}") } } I connected it with fragment…
0
votes
1 answer

DataBinding & LiveData : two implementations (Kotlin & Java) and can't make the Java impl working

I'm facing issues while using DataBinding and LiveData in a Java projet. I followed a previous course in Kotlin and when I try to implement the same behaviors I just can't make it work. I'm clearly missing something in terms of understanding so I'd…
0
votes
1 answer

How do I cast custom MutableLiveData to custom LiveData?

suppose there are 2 classes: class MyLiveData:LiveData() class MyMutableLiveData:MutableLiveData() Casting from MutableLiveData to LiveData is permitted: val ld1=MutableLiveData() val ld2:LiveData = ld1 //ok But you can't…
undefined
  • 623
  • 7
  • 27
0
votes
1 answer

MutableLiveData for collections

I request data from server by bunches and store it in the array.To track fetching of the next bunch of the data I have this class.In the addItems method I notify diffObservers and pass list of new items: class…
undefined
  • 623
  • 7
  • 27
0
votes
0 answers

Live Data loading previous result first and then new response loaded to recylerview

Actually I am getting a response using liveData+retrofit from API everything working fine in the first try ..if call the same API again its showing previous response first and then new response override the previous one. I debug the code and it…
Bunny
  • 1,044
  • 12
  • 23
0
votes
2 answers

call MutableLiveData web service agine to update the list

I use MVVM structure in my project. I have the main fragment with list observed a web service as you can see in the code fragment : mViewModel.getHomePageList().observe(this, homeDataWrapper -> { if (homeDataWrapper!=null) { …
0
votes
1 answer

How to set LiveData> to MutableLiveData>?

I am developing in Android, and try to get the LiveData> via following function. private fun getDataList(): LiveData> { return room.getData() } And I create a parameter like the following: private var…
Wun
  • 6,211
  • 11
  • 56
  • 101
0
votes
2 answers

How to properly call network fetching function from view model

How should I call the function QueryUtils.fetchData(REQUEST_URL) inside of ViewModel, it returns List. This code fetches data the way it should, but it doesn't display it probably because it already sets data before it is…
Kica
  • 3
  • 2
0
votes
1 answer

How can I fix this DataBinding and LiveData code?

I am trying to connect DataBinding with LiveData, but run into some problems, that i dont know how to fix. I am not sure if i did something wrong with the LifecycleOwner, but its not working. Also some explanation why the correct way is right is…
user11812815