Questions tagged [mutablelivedata]

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

320 questions
0
votes
1 answer

Periodically get updated OkHttp response using Android Architecture: LiveData and update Map markers

I have made a transport application that shows bus locations. I am currently trying to refactor my code so that I can smoothly animate markers (bus locations) and have seen that LiveData could be useful for cleaning up my code. I am using OkHttp to…
0
votes
2 answers

Using a custom setter for a lazy delegate

I have alot of repeated code, and since I'm fairly new to Kotlin, I want to learn and try to take advantage of it as much as possible. I have many lazily declared MutableLiveData properties, and somewhere down the code I'm checking each one to…
0
votes
1 answer

How to relay retrofit response from data repository to view model using mutable live data in android?

I am able to make a network request and get back a response inside my data repository but not able to get that inside my view model. Data repository: public class DataRepository { private APIService apiService; private static DataRepository…
0
votes
2 answers

MutableliveData returns null from repository to singleLiveEvent

I am trying to call the network on button click. I am using singleLiveEvent wrapper because the data need to be sent to the server and retrieve the response only on button click. I am using Volley for GET and POST calls. I am getting response on…
0
votes
1 answer

Why onChange result is "false" in test LiveData

It's first my post on stackoverflow and i'm beginer in kotlin, Lifecycle, need help with it. I lost 2 days with it and need help. I have SplashViewModel class class SplashViewModel @Inject constructor( private val configuration: IConfiguration, …
0
votes
1 answer

MutableLiveData doesn't work, ObservableField does - why?

I have a very simple code in XML:
Spook
  • 25,318
  • 18
  • 90
  • 167
0
votes
1 answer

Android LiveData: Unable to receive updates on Observable?

I am using android Architecture Component LiveData to notify UI using Observable LiveData but it is not getting triggered. below is the code snippet. AuthRepository class AuthRepository(private val repository:Avails) { fun auth(mobile:…
Pinakin Kansara
  • 2,273
  • 3
  • 22
  • 35
0
votes
1 answer

LiveData not triggering twice in case of network request failing

My LiveData object is called twice when my httprequest is succefull, but in case of an error, it's only called once, causing the UI to display an empty list since my Error verification was skipped since there was no alert fired. My repository code …
Greggz
  • 1,873
  • 1
  • 12
  • 31
0
votes
1 answer

Why is LiveData onChanged called before data change is made?

Context Using MutableLiveData to hold a value. Button click should increment the value. Problem MutableLiveData's Observer.onChanged() appears to be called before MutableLiveData.setValue() is used to change the value. For example, before Button…
surajs02
  • 451
  • 7
  • 18
0
votes
3 answers

Why do we need LiveData and ViewModel

I have used LiveData and ViewModel example but i dont understand use of this feature because i can change value directly without use this feature even this is growing number of line in code by using observing code and same as in ViewModel by…
Salman
  • 159
  • 1
  • 2
  • 7
0
votes
1 answer

Android room loading multiple data at once how to know that all requests are finished

So I have Room database and I'm using MutableLiveData to load four lists from database in one screen each of these four lists have separate callbacks which are called when data is loaded and I have progress bar which I show when data starts loading…
LeTadas
  • 3,436
  • 9
  • 33
  • 65
-1
votes
1 answer

How to control play/pause state of MediaBrowserServiceCompat from RecyclerView?

I have an app that uses MediaBrowserServiceCompat to play audio. I have a RecyclerView that displays a list of media items, and I want to be able to control the play and pause state of each item from within the RecyclerView. For example, I want to…
-1
votes
2 answers

MutableLiveData> vs MutableLiveData>. Why should we use List here?

I created a library here: https://github.com/chanjungkim/ALiveData This library is made because of MutableLiveData>. Many people who learns about LiveData complains or they are confused with this type when they need to manipulate(add,…
c-an
  • 3,543
  • 5
  • 35
  • 82
-1
votes
1 answer

Android kotlin mvvm update live data

How to update mutable live data in kotlin following is my entity in viewModel private val searchResult = MutableLiveData>() following is searchResult pojo data class SearchResult( @field:SerializedName("Response") val…
amodkanthe
  • 4,345
  • 6
  • 36
  • 77
-1
votes
1 answer

Trouble with ViewModel, LiveData

I have main Fragment and DialogFragment. In Start i go in dialogFragment with list of city and get one for save in LiveData listOfCities.setOnItemClickListener { parent, view, position, id -> …
1 2 3
21
22