Questions regarding applying a Model-View-ViewModel in android application
Questions tagged [android-mvvm]
773 questions
0
votes
1 answer
Dagger 2 multiple Repositories
So i am new to Dagger 2 dependency injection. I have created a custom ViewModelFactory class which returns my ViewModel.
@Singleton
public class CustomViewModelFactory implements ViewModelProvider.Factory {
private final MyCatchesRepository…

pavlos
- 547
- 1
- 9
- 23
0
votes
1 answer
Android MVVM: Observing database changes from broadcast receiver
In my app, I need to add/remove/update data in my db from a BroadcastReceiver. I am wondering what are the best practices regarding this. Since the onReceive is called on the main thread, I need a way to run the queries on a worker thread and on…

varunkr
- 5,364
- 11
- 50
- 99
0
votes
1 answer
How to parse success body response on http exception 401?
I have trying to parse actual response body even if server returns 401 HTTP Exception.
protected inline fun executeNetworkCall(
crossinline request: () -> Single,
crossinline successful: (t:…

Ankit Kumar
- 3,663
- 2
- 26
- 38
0
votes
1 answer
Does an app built with Architecture Components make it "MVVM" and if yes, which parts of the app relate to which layer of MVVM?
I couldn't find any source that answers this question directly:
Are Android Architecture Components made to follow an MVVM architecture (if implemented properly)? And if yes, which part of the app (Activity/Fragment, ViewModel, repository, database,…

Florian Walther
- 6,237
- 5
- 46
- 104
0
votes
1 answer
Android: Exception using MVVM pattern architecture observe
I'm trying to run an app adopting MVVM pattern architecture, but I'm getting an exception that I can't solve.
I have my MainActivity.java which has an observe to the firstTime() method in the MainViewModel.java.
MainActivity.java
(...)
…

porthfind
- 1,581
- 3
- 17
- 30
0
votes
0 answers
Android Architecture Components View Model
I'm try to update my school project with android architecture components. In these days I'm researching about ViewModel component in architecture components. I read lots of articles.
I know using viewmodel is used to provide data to the UI and…

Pasindu Weerakoon
- 588
- 1
- 11
- 39
0
votes
1 answer
How to make activity to show data got from the service?
I need write a service which will update the list in MainActivity every 30sec. I use MVVM with ViewModel and LiveData and so my Service class looks like this:
public class ArticleJobService extends JobService {
public static String TAG =…

sunflower20
- 469
- 3
- 8
- 20
0
votes
0 answers
How to use app:items="@{viewModel.items}" attribute with RecyclerView, MVVM and data binding?
There is an app:items="" attribute for RecyclerView, how is this attribute used with MVVM and android.arch.lifecycle.ViewModel, not ViewModel that extends BaseObservable? items could be LiveData, List or ObservableArrayList, with which collection…

Thracian
- 43,021
- 16
- 133
- 222
0
votes
1 answer
Is it possible to set text of TextView with a method of ViewModel that returns String?
Is it possible to change text of TextView with a method that returns String?
For training purposes i created this ViewModel class, it puts User object into List mUserList and i wonder if i can set first names of this users as text of TextView…

Thracian
- 43,021
- 16
- 133
- 222
0
votes
0 answers
a library makes my project slower
I new in android app development.I have build simple android library which having class base activity BaseActivity
i have upload library to github : https://github.com/ubheamar/android_core/
now i am trying to use jitpack to get library for android…

Amar Ubhe
- 101
- 6
0
votes
1 answer
Android MVVM architecture - Android references/imports in ViewModel
Based on the idea that you should not pass and Android view's or other pure Android components to ViewModel, or have android imports there, consider the next use case:
From my Fragment I want to launch some sort of image processing action and for…

RonTr
- 137
- 10
0
votes
1 answer
In Android, if I use binding, how to apply ClickableSpan?
I know that if binding is not applied, then I can use Textview.setText(ClickableSpan) to apply spannig effect to make part of the text clickable. However, my app used binding and the textview's text is binded to a ViewModel inside xml like…

litaoshen
- 1,762
- 1
- 20
- 36
0
votes
1 answer
Android Clean MVVM With Dagger 2
I've just got back to the Java&Android world.
In my search for a good project starters that will leverage compilation time DI and MvvM, I found these two:
Writing Testable Android MVVM
Countries - A sample Android app
Now to my problem...
I'd…

Tomer
- 4,382
- 5
- 38
- 48
0
votes
2 answers
how to change the structure of already developed android project?
I am just a beginner and at the time of developing i was blind about following an architecture, but now I've come across many awesome architecture and frameworks out there which i can follow to make code clean and easy to maintain.. so I have 3…

Niki
- 1,566
- 1
- 19
- 36
0
votes
1 answer
How can I get selected Item position and Item Details (Model) from RecyclerView?
I have used MVVM, Databinding and Retrofit to develop this app. I have loaded data to RecyclerView. When I will click on any item on RecyclerView, I need the position and details information of this position. Because I will show this information in…

durlove roy
- 229
- 4
- 12