Questions tagged [mutablelivedata]

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

320 questions
0
votes
0 answers

Does MutableLivedata mean getting live updates from server like sockets?

how does MutableLivedata work exactly? UI components observe the MutableLiveData objects, and they are notified of data updates only when there is a change in the observed data. How does MutableLivedata know that there is change in data or new data…
0
votes
0 answers

Is it thread safy to modify a mutable variable for a mutableStateFlow in producer and consumer concurrently?

Refer to following codes: @Test fun test() = runBlocking { val tag = testName.methodName var mutFlow = MutableStateFlow(mutableListOf()) val imFlow = mutFlow.asStateFlow() Log.d(tag, "mutable value is…
progquester
  • 1,228
  • 14
  • 23
0
votes
1 answer

Access MutableLiveData Properties

I'm new to programming and starting to work through some tutorials in Kotlin for Android. Currently, I'm looking at data binding and view model design patterns. I know that operations on mutablelivedata should not be in the main activity, so I've…
whoosh
  • 25
  • 3
0
votes
1 answer

How to trigger MutableLiveData change in ui?

In my view model I'm using an observable with zip operator to combine two data sets where I then create a new object with data from each source. I post the value of the object to my ui. I need to be able to refresh the content of the object…
0
votes
0 answers

viewmodel and LiveData in Android

Sorry I have to delete my post because I was not getting answers from the stackflow community. I felt it was not necessary to leave the post here then.
Gab
  • 11
  • 2
0
votes
0 answers

another data in mutablelivedata returning empty

another data in mutablelivedata I want. But normally running function doesn't work inside this function fun getFirebaseBasketList(): MutableLiveData> { database.addValueEventListener(object : ValueEventListener { …
0
votes
1 answer

Android ViewModel deletes all my data when observing

I am developing an app with Android Studio, and I wish to use MutableLiveData alongside with RecyclerView. Problem is, when I add a new item to the MutableLiveData, it gets updated, then going back to the previous fragment, the item gets erased for…
0
votes
0 answers

Saving audios and videos files paths in room database and auto update with new files saved in folders

I am developing an audio/video app in which I use Room database to save files paths so that recycler view adapter is populated quickly. This works but if I add new files to folders, those files are not updated in adapter. I am using Livedata but…
Hanif Khan
  • 31
  • 3
0
votes
1 answer

MutableLiveData not posting value

I'm trying to post a state as "Loading" to display a progress bar to the user while downloading data from the server, it looks like this: private fun loadBottomSheetItems(currentViewState: BusinessMapViewState.Display, getBusinessByIdsRequest:…
0
votes
1 answer

How to update LiveData from another class?

I have this on my GroupDescriptionActivity class: GroupDescriptionViewModel mFavViewModel; ArrayList mFav; mFavViewModel = new ViewModelProvider(this).get(GroupDescriptionViewModel.class); final Observer>…
0
votes
0 answers

How to test LiveData in ViewModel using coroutines

I am trying to test a function that executes a block of code launching a new coroutine, using this extension function: fun ViewModel.execute(block: () -> Unit) = viewModelScope.launch(Dispatchers.IO) { block() } Basically is launching a new…
0
votes
2 answers

How to use Live Data correctly in my case Android kotlin

HomeFragment Everything seems to be done correctly, but when you flip the screen, the resulting value from the EditText disappears from the TextView. What to do tell me pls HomeViewModel MainActivity
Timo4ka
  • 23
  • 7
0
votes
0 answers

LiveData in Android - always get null

I have a trouble with Live Data in Android Studio. I can't get the data from it or put the new value. I have entity, it calls BeeQueen: @Entity public class BeeQueen { @PrimaryKey(autoGenerate = true) public int id; private int…
0
votes
1 answer

viewmodels postValue called from dialog doesn't change UI in MainActivity

I am starting off with my ViewModel (sry for mixing Kotlin with Java) class MainViewModel : ViewModel() { val textViewIP: MutableLiveData = MutableLiveData() } In my DialogFragment, I change the MutableLiveData when pressing the…
Pezcraft
  • 270
  • 3
  • 15
0
votes
1 answer

Notify MutableLiveData when another MutableLiveData value changes

In my ViewModel I have the code shown below: private val _sender = MutableLiveData() val sender: LiveData get() = _sender private val _receiverListItems:…