Questions tagged [android-mvvm]

Questions regarding applying a Model-View-ViewModel in android application

773 questions
3
votes
1 answer

How to show alertDialog Box using mvvm pattern

I am working on a login module where I have to show alert dialog if the login is unsuccessful. I have a authentication process in viewmodel and I have to display an error in alert dialog.How it can be done?
Sam
  • 571
  • 1
  • 6
  • 22
3
votes
1 answer

Communication between views in MVVM

I'm new to Android Architecture Components / MVVM and would like to know what's the best way to implement communication between views. So let's say I have A_View, A_View_Model, B_View and B_View_Model classes. As the user is interacting with A_View…
kotsen
  • 119
  • 1
  • 4
3
votes
1 answer

Android how to handle recyclerview clicks in mvvm architecture

I want to handle clicks in my recyclerview rows and currently pass my presenter to my viewholder bindings. Presenter interface: interface IMainPresenter{ public void showDetail(Pojo pojo); } Viewholder: class ViewHolder(itemView: View, val…
ir2pid
  • 5,604
  • 12
  • 63
  • 107
3
votes
1 answer

Applying MVVM between ViewModel and Fragment/Activity interactions and communication

I am investing a lot of time into properly understanding of architecture components and the how everything fits into MVVM pattern. So far here's how I see things (without doing Dagger injection as I haven't got that far yet): a) UserEntity is a…
3
votes
0 answers

todo-mvvm-xxx - Communication between viewmodels

Problem: I have activity which have shared button , shared title,shared process bar and container in the middle of the screen where fragments replaced. so i have viewmodel of the acitivty - ActivityViewModel and inside of it there is observables…
3
votes
2 answers

Cannot create instance of viewmodel

Hello I am new to MVVM in android and working with livedata. I am trying to create an instance of my viewmodel. I feel the issue is that i have not passed my repository to my viewmodel constructor. I keep getting cannot create instance of viewmodel.…
inhaler
  • 415
  • 2
  • 7
  • 20
3
votes
1 answer

Using LiveData and ViewModel without using Room

For android MVVM architecture, in all the examples that I have seen, people either use Room to store/retrieve data or they get data directly from API calls through the Repository class. I'm neither doing an API call nor using I have Room database to…
3
votes
2 answers

Correct way of handling data and loading indicator in recyclerview using ViewModel, LiveData and RxJava

I have the following UI flow when searching items from a data source: Display a progress indicator while retrieving from source -> assign livedata to Outcome.loading(true) Display results -> assign LiveData Outcome.success(results) Hide progress…
Mark Pazon
  • 6,167
  • 2
  • 34
  • 50
3
votes
1 answer

Error: Cannot find ActivitySplashBinding

I am trying to check that if user is logged on or not. If yes then show a specific view group otherwise show different view group. To check whether user is logged on or not I am fetching the user from shared preference (at the time of login user is…
3
votes
1 answer

How to set Adapter in MVVM using databinding

I am new to MVVM and DataBinding. I have set up ViewHolder and Adapter. Now I don't know how to set adapter in activity. Should I use another ViewModel to fill the arraylist of objects? If yes, then how to do it? Code i have implemented is as…
3
votes
1 answer

Navigating to another activity using databinding in mvvp structure

I am learning data binding library and I am totally new to this. My question is how to navigate to another activity on data binding. Can I do it just like we do it in MVC or I have to put that code in ViewModel. Please help me. Here is my…
Riddhi Shah
  • 3,092
  • 5
  • 36
  • 56
3
votes
1 answer

What is the difference between ViewModel and AndroidViewModel

For anyone having this question, As per Android Documentation, Since the ViewModel outlives specific activity and fragment instantiations, it should never reference a View, or any class that may hold a reference to the activity context. If the…
Rahul
  • 4,699
  • 5
  • 26
  • 38
2
votes
0 answers

How to split complicated ViewModel into reusable parts? Using MVVM, android jetpack compose

I have an application with MVVM pattern with jetpack compose, the code style is similar with NowInAndroid app structure. Now I faced the issue, please help with examples, that I can investigate and move further. I have complicated screen, for…
2
votes
0 answers

Observers don't get notified when LiveData is set through FileObserver

I have a sharedViewModel with LiveData properties. MainActivity: private val logViewModel by viewModels() fun startLocationUpdates() { val locationItem = LocationItem(...) logViewModel.addLogEntry(locationItem) …
Houman
  • 64,245
  • 87
  • 278
  • 460
2
votes
0 answers

Is there any rule to follow to create mvvm project structure in android studio project

Generally, MVVM or MVC or MVP , we are allocating classes under the package structure, as per architecture pattern role and responsible of each components. Ex: View - Design/user interaction related classes. ex: Activity/Fragments Model - it helps…
harikrishnan
  • 1,985
  • 4
  • 32
  • 63