Category : android-mvvm

I need to set the name of chosen category, below is the category object code and methods I call by clicking. Grateful for helping. categoryItem object: @Entity(tableName = "category_table") @Parcelize data class CategoryItem( val categoryName: String, val categoryNumber: Int, val categoryShown: Boolean = false, @PrimaryKey(autoGenerate = true) var id: Int = 0 ) : Parcelable ..

Read more

I am trying to enqueue a WorkManager worker through a repository Method in order to insert some data inside my database but i can’t seem to figure out what type of context i should pass inside the getInstance(). Obviously the Context i am giving is wrong since i am getting a NullPointerException. I am new ..

Read more

I have an application architectured by: View -> ViewModel -> Repository -> Datasource My DataSource is consuming a webservice and then receiving Soap object, which I want to transform to a custom Pojo object. So, by using RxJava I am calling the datasource method by following this flow: ViewModel repository.webserviceCall(data)… .subscribe(); Repository public Single<SoapObject> webserviceCall(String ..

Read more

Error: error: [Dagger/MissingBinding] java.util.ArrayList<java.lang.Integer> cannot be provided without an @Inject constructor or an @Provides-annotated method. public abstract static class SingletonC implements HiltWrapper_ActivityRetainedComponentManager_LifecycleComponentBuilderEntryPoint, javax.inject.Provider<java.util.ArrayList<java.lang.Integer>> is injected at space.rodionov.swedishdriller.DrillerViewModel_AssistedFactory(�, drillerCatList, �) space.rodionov.swedishdriller.DrillerViewModel_AssistedFactory is injected at space.rodionov.swedishdriller.DrillerViewModel_HiltModule.bind(factory) java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>> is injected at androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule.provideFactory(�, viewModelFactories) @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory java.util.Set<androidx.lifecycle.ViewModelProvider.Factory> is requested at dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories.ActivityEntryPoint.getActivityViewModelFactory() [space.rodionov.swedishdriller.SwedishDrillerApplication_HiltComponents.SingletonC ? space.rodionov.swedishdriller.SwedishDrillerApplication_HiltComponents.ActivityRetainedC ? space.rodionov.swedishdriller.SwedishDrillerApplication_HiltComponents.ActivityC] The following ..

Read more

In ViewModel: val drillerCatList: List<Int> = emptyList() val shownCategoriesFlow = wordDao.getShownCategories() // which returns type Flow<List<CategoryItem>> Catigory object: data class CategoryItem( val categoryName: String, val categoryNumber: Int, val categoryShown: Boolean = false, @PrimaryKey(autoGenerate = true) var id: Int = 0 ) : Parcelable { } How can I retrieve all categoryNumber values from shownCategoriesFlow: FLow<List> ..

Read more

I get this error: Cannot access database on the main thread since it may potentially lock the UI for a long period of time. It happens when I launch fun turnAllWordsOn() in the ViewModel (code below). This function launches coroutine, and I thought that coroutine always works on the backgroung thread. So why I get ..

Read more

I tried to show items on recycle view using MVVM, but when called notifyDataSetChanged() it returned java.lang.NullPointerException: Attempt to invoke virtual method ‘void madushan.max.tea_application.adapter.UserAdapter.notifyDataSetChanged()’ on a null object reference. Fragmnet class public class fragmentEmployee extends Fragment { private FragmentEmployeeBinding binding; private ViewGroup viewGroup; private View view; private RecyclerView mRecycleView; private UserAdapter mAdapter; private EmployeeRegisterViewModel viewModel; ..

Read more