I want to display favored items from two tables: Item and ItemMoto. Both tables share same table Favourite. Portion of files are" FavouriteListFragment.java public class FavouriteListFragment extends PSFragment implements DataBoundListAdapter.DiffUtilDispatchedInterface { private final androidx.databinding.DataBindingComponent dataBindingComponent = new FragmentDataBindingComponent(this); private FavouriteViewModel favouriteViewModel; private FavouriteMotoViewModel favouriteViewModelMoto; @VisibleForTesting private AutoClearedValue<FragmentFavouriteListBinding> binding; private AutoClearedValue<ItemVerticalListAdapter> adapter; private AutoClearedValue<ItemAutoVerticalListAdapter> adapterMoto; @Override ..
Category : mediatorlivedata
I’ve moved my mediator and mutable live data in abstract class because of the need to reuse it. Now, whenever my class, that extends my abstract class, changes dataMutable value, dataMediator.addSource() doesn’t get triggered. I’ve even written println("dataMediator.addSource()") which never gets called. When those methods where in my main class, everything worked fine. What am ..
Basically, I am fetching the products list from this API using Retrofit into a MediatorLiveData inside ProductsRepository class. But, the problem is, when I try to observe the LiveData I get null. Here is my code snippet: ProductsRepository: @MainScope class ProductsRepository @Inject constructor(private val productsApi: ProductsApi) { private val products: MediatorLiveData<ProductsResource<List<ProductsModel>>> = MediatorLiveData() fun getProducts(): ..
I’m posting my room query result using the below code _data.postValue(databaseImpl.findRepoById(id).value) But it seems the returned object is empty. I’m guessing we need to observe databaseImpl.findRepoById(id), not access it directly but since it’s in a viewmodel I don’t have a lifecycleOwner to assign to the room query livedata. databaseImpl.observe(this, Observer { //!!this is modelview and ..
I have two classes Route and Station, Route has an ArrayList<Station>, see the definitions below @Entity(foreignKeys = @ForeignKey(entity = Route.class, parentColumns = "routeId", childColumns = "routeIdForeignKey onDelete = ForeignKey.CASCADE)) public class Station { @PrimaryKey(autoGenerate = true) private Long stationId; @SerializedName("stationName") @Expose private String stationName; @SerializedName("streetName") @Expose private String streetName; @SerializedName("arrivalHour") @Expose private String arrivalHour; @SerializedName("departureHour") ..
Code: val btnClickable = MediatorLiveData<Boolean>().apply { addSource(idText) { value = checkFullText() } addSource(passwordText) { value = checkFullText() } } I want to change this Kotlin code into Java. but I don’t know how. Source: Android..
Here is my problem. I have to generate data from three different LiveData objects into one object. Two of them depending of one of them. The observer should only be triggered if all three object data was received. Here is an example: The resulting object contains information of a product and a specific review rating ..
I have two livedatas startedAt & finishedAt and want to use them in a transformation that depend on both these values…i tried combine them using mediatorliveData fun <A, B> LiveData<A>.combine(other: LiveData<B>): PairLiveData<A, B> { return PairLiveData(this, other) } class PairLiveData<A, B>(first: LiveData<A>, second: LiveData<B>) : MediatorLiveData<Pair<A?, B?>>() { init { addSource(first) { value = it ..
I have an abstract class, with a MediatorLiveData object in it. This object has a number of sources, one of which depends on the childs class, and is abstract in the parent class. Adding the sources in an init block causes a NullPointerException at runtime, because at the time the init block adds the source, ..
Recent Comments