Viewmodel Questions
Ad
Activity/Fragment and ViewModel in Adapter good practice?
Let's assume that we have activity/fragment which contains a recyclerview. furthermore, it sets an adapter. for the sake of the example, let's say
Why (Not?) Pass Context to Android ViewModelFactory
I am refactoring applications that pass "application context" to the view model factory and is accessed in the view model. is there a
lateinit property apiInterface has not been initialized kotlin.UninitializedPropertyAccessException:?
I am writing unit test for my viewmodel when i run test i am getting following exception lateinit property apiinterface has not
Swift, fetching data in viewmodel and passing it to view
I'm trying to update data in my viewmodel here is my viewmodel; import swiftui import corelocation final class
Shared viewModel achived fragment lifecycle
How i can use shared viewmodel with fragments without activity? like in code but in place of requireactivity() use parentfragment. in this case
Composable is recomposing endlessly after flow collect
My composable is recomposing endlessly after flow collect and navigating to a new screen. i can't understand why. i'm using firebase for
How to get LiveData from Room?
I'm trying to get livedata from room. so my recycleview can have live updates if anything in database is changed i have tried with out
what is ViewModelFactory
What is viewmodelfactory and when and why should i use it i am new to android and actually i can't understand these concepts in mvvm
Dagger2 + ViewModel + Repository
I am new to dagger 2 and trying to implement it in kotlin. here i am trying to inject my repository object into viewmodel. i am successfully able
CountDownTimer : In Activity, ViewModel or separate class?
I would like to create a countdowntimer which will trigger events that will update the ui (trigger popup, start an animation,
Ad
LiveData,how to avoid the first callback when register observer
I want to load tasks in a fragment, in fragment's onviewcreated,i register the livedata observer, in fragment's onresume,i load the
Scoping a viewmodel to multiple fragments (not activity) using the navigation component
I'm using the navigation component, i want a view model to be shared between a few fragments but they should be cleared when i leave the fragments
Android Kotlin Coroutines: Is using Global scope an anti-pattern?
This is rather a question for advise then how to. i am using viewmodelscope to launch jobs to interact with my database in my viewmodel.
Android Room + ViewModel usage
I want to use android's room + viewmodel components for my app, but i'm not quite sure how. one of my database tables is going to represent
MVVM - Accessing ViewModel/SQLite in a BroadcastReceiver started from a notification when app is closed
I have a reminder notification that is sent every few days. the sending of that notification is triggered with a repeating
android - room - return count of data by query
I want to return count of rows from a certain query to my view ,i'm using view model this is my dao class:
ViewModel in architect component - android
I have a lot of fragment base architect component. is this true that i create viewmodel for per
Registering an Observer vs setting an handler
I'm setting up a mvvm pattern in my android app using the viewmodel class from android. now i need to send events (eventually
Can't get an INSTANCE of a DB using the AndroidViewModel superclass and Room
In my mvvm app, i am extending androidviewmodel and through a repository class, i am trying to get an instance of a db (in a separate
How to make MVRX viewmodels work with dagger2?
Edit adding the @viewmodelkey and making sure all the viewmodels have the @inject annotation did the trick
Ad
When KOIN graph reassembling, delegate function viewmodel() not refreshing viewmodel instance
We are using in our project koin like di library. in some
Is the View or the ViewModel responsible for transforming data from a Model to be presented in the UI?
I am new to mvvm pattern, and this is a general question for me but i will use a specific example. i have: a data class
Get one value from LiveData
I have livedata for books in viewmodel's constructor: livedata<list<book>> books; public
Encapsulation for ObservableBoolean in ViewModel class
In viewmodel we can apply encapsulation for mutablelivedata as shown in
MVVM architecture with Interactors/UseCases
Context so, i've been working with the mvvm architecture just for a couple of projects. i'm still trying to figure out
Inject provider of ViewModelProvider.Factory into esspresso test
I have custom implementation of viewmodel.factory which is provided by lambda injected by dagger2
@RawQuery with ViewModel
I followed this room with a
ViewPager with viewmodel and live data , all 6 tabs data is replaced by last tab data
I am working on a viewpager with 6 tabs where it has only one fragment timeslistfragment depending
Saving activity's state with onSaveInstanceState() and ViewModel
I was left with some questions regarding viewmodels after reading this:
Android: ViewModel test using kotlin coroutines not working
I'm using coroutines for the first time and i'm having troubles testing my work on a viewmodel. the test fails with
It is ok to call observeForever() on Livedata returned by Transformations.map() inside ViewModel?
I tried to use livedata transformations.map() to check the result and update the ui. but transformations.map() callback not triggered without an
Ad
How to handle exception in mvvm android and pass that exception to our view
I am using mvvm architecture to hit a web service through retrofit in android studio. i have handled the response of the service in my view class.
Enable a button when all EditText complete
I would like to enable a appcompatbutton when all fields in a form are complete. i am using a viewmodel and would like to use databinding
Why a viewmodel factory is needed in Android?
We have been discussing about this but we don't know the reason of creating a viewmodel factory to create a viewmodel instead of instantiate the
In Activity/Fragment, How to get/wait the return value from ViewModel coroutines operation?
Following the codelab demo from google
How to restore checkBox state in Android RecyclerView list items on Rotation of device
My current android application contains a recyclerview that has a checkbox present in each item within the list. my issue is that on
What is the difference between ViewModelProviders and ViewModelProvider class?
I saw two classes with a similar name, viewmodelproviders, and viewmodelprovider. can anyone explain what are the difference between these
The retrofit call not update viewmodel or viewmodel not update the view
I try get a user from a rest api for do login in my android app for get this i have the next code loginactivity.java
Convert JSON to ViewModel and pass with token to Controller
In my asp:net mvc app i have a method as shown below and i try to pass the form data (single item of a list) to the controller. i also need to
Android - I can access ViewModel method from fragment but the method does not return the list
I recently started studying android kotlin and i am expecting this to have a very simple answer but i have a viewmodel which has a method called
Boundary Callback (Android Paging Library) with CoroutineScope
I'm trying to implement android paging library with viewmodel and kotlin coroutines i have a
UI not updated when ViewModel value changed
I have created sample app to demo my question: a textview and a button, text view visibility is bound to
Ad
Can i use a viewmodel that is observed for two activities?
I'm working on a new project that implements mvvm. can i use a viewmodel that is observed for two activities ? or should i make one viewmodel for
ViewModelProviders is deprecated in 1.1.0
Looking at the google docs for
android.arch.lifecycle.ViewModelProviders is not recognized in Kotlin code
For java project, in order to recognize android.arch.lifecycle.viewmodelproviders, i simply define the following in my build
Why AdnroidInjector.inject(fragment) uses deprecated android.support.v4.app.Fragment
I'm using dagger2 for di in android app, i want inject viewmodel in a fragment by androidinjector and have this two line
call super in constructor of ViewModel instance class : Kotlin
I am new to kotlin. here is is my java code i wanted to convert it in kotlin public class favouritesviewmodel extends
Trigger update for a LiveData member when another LiveData is updated in the view model
In a word game app i share a model between an activity and a fragment: public class mainviewmodel extends androidviewmodel {
Observe a MutableLiveData list
I am using live data in my application and i have a view model that extends from viewmodel. in my view model, i have a list
ViewModel not observed by AppCompatActivity
I'm trying to use viewmodel together within my earthquakeactivity but i keep getting this error: wrong 1st argument
Best approach for unit-testing scoped viewmodels
When dealing with coroutines inside a viewmodel is best to have said viewmodel implement coroutinescope so all coroutines are
Android ViewModel - how to force recreation on certain configuration changes
Viewmodel's purpose is to retain data on life
ViewModel manipulation in MVVM Architecture
My problem is, that i need to preprocess data from the room database before showing it in my view. therefore here some context of
Ad
How to use 4 simple ViewModels with the same Fragment?
I have an app, which displays 4 lists of words in a fragment (reusing the same class!): 2-letter words 3-letter words
Accessing data from ROOM DB using ViewModel and ID
Suppose i have got a list of data in the room db. let the data be: setid, formid, formname. there can be multiple formid in the single setid.
Room and ViewModel, multiple queries?
So i have an android application that has a room database, this backend is managed by a class that acts as a repository which feeds my view model,
Preserve data through memory cleaners
I have an issue with the preserving bundled data of an activity. certain memory cleaners (such as clean master), as well as the gc of certain
Kotlin does not understand ViewModelProviders.of(activity ?: fragment)
Inside my fragment i initialize a viewmodel using viewmodelproviders. i want it to take its
Loading data in ViewModel that have been retrieved in SplashActvity
I'm new with the viewmodel and i understand that it's a powerful and easy way to communicate with fragments. my problem is the following
Why repository sends to constructor of ViewModel?
I'm studying google architecture components with mvvm and noticed that repository sends to constructor of viewmodel. the
I am getting Unresolved Reference when compiling in kotlin
I am new in kotlin and i am getting unresolved reference when compiling it can not get a reference to my class, here are both
Load ViewModel instance in another activity
When app start i need to download data and populate all viewmodels to avoid slowdowns during the app usage. first activity is:
Should 2 Activity's have separate ViewModels if the method usages don't overlap?
I have 1 activity that only displays and deletes notes from a
Does calling a ViewModel instance reset the LiveData?
In kotlin i'm using viewmodel = viewmodelproviders.of(this).get(homeviewmodel::class.java) to retrieve a
Ad
Android ViewModel design/architecture
I'm an android beginner, and just looking for some advice with regard to app architecture - specifically relating to using viewmodels. there is no
How does Flutter maintain consistency without loosing its data on any orientation change?
I have been coding into flutter and is wondering if there is any kind of viewmodel thing that is supported in flutter. main purpose of viemodel
How can I create ViewModel and inject repository to it with dagger 2?
I try understanding viewmodel. i create viewmodel: public class usersviewmodel extends viewmodel { private final
Create custom params android viewmodel class
This will create myviewmodel object with default or zero parameters. myactivity
When is the viewmodel onCleared called
Are viewmodels independent of activity/fragment lifecycles or just their configuration changes. when will they cease to exist and the subsequent
Android MVVM: How to handle network request failiures?
I am new to android arch components. i am trying to make a basic todo app using android view model and live data. what is the best way to make
Android Architecture Components: ViewModel keeps getting re-initialised
I have an activity that uses the
Struggle to get the same ViewModel instance
I'm not sure if i understand viewmodel architecture correctly in android. i suppose viewmodel lifecycle is tie to the activity so we
ViewModel method name convention
What is the best way to name methods in the viewmodel classes? based on its action/behavior or the lifecycle of the
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
Android ViewModel recreated on screen rotation
I found a case when architecture components viewmodel isn't retained - in short it goes as follows: activity is started
Ad
Room database Livedata getValue() returns null
I was trying to fetch a list of custom object data from room using livedata and viewmodel. while using livedata's getvalue() method, returns null
How to generate composed view models with temporary sub views?
Scenario i have a quizz generator, which generates a sequence of quizzes of different classes. the sequence is of unlimited length.
How to show different text in repeating notification Android
I have a method getrandomwordfornotification in viewmodel(watch listfragment) which returns random word from database. and i want to show returned
ExoPlayer in MVVM
I am trying to use exoplayer in my app, and i am following mvvm design pattern, i want to make playerviewmodel class where it handle all the
Data binding LiveData from Transformation - Android Kotlin
I'm learning kotlin and android architecture components. i have a simple use case of a map toggle button on a google map. i want to use
Android ViewModel doesn't survive fragment change
I've been trying to share information between fragments using viewmodel's and livedata's. but when i change from first fragment to
ViewModelProviders.of(getActivity()) "Cannot resolve method of(android.app.Activity)"
I'm currently trying to share data between my two fragments with the help of a view model
NativeScript - What is the difference between viewModel.foo and viewModel.get("foo")?
Take the following simplified viewmodel: const observablemodule = require("tns-core-modules/data/observable"); function
Is there an issue with setting sharedPreferences from the activity to the viewModel? Android - MVVM
After initializing my viewmodel from the activity, i initialize the sharedpreference variable (sharedprefs) in the viewmodel from the
Type mismatch. Required: Result<NewsResponse>! Found: Result<Response<NewsResponse>>?
I am developing android app and i have implemented success and failure cases in viemodel class but i am getting following mismatch type mismatch.
How to create an instances of the class in Koin correctly?
I'm learning koin right now and here is my trouble. when i'm trying to run the application, i get this error: kt:23) at
Ad
Shared viewModel with assisted injection and hilt
I have an activity. this activity is receiving some arguments. at the moment, i'm able to create a viewmodel with those parameters
How does ViewModelProviders know when there is a configuration change VS user explicitly creates a new activity?
Public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) {
Android different ways to create viewModel object which one to use when?
I recently started with the viewmodel and androidviewmodel, i see there are different approach to initialise a viewmodel instance, for me all
How to add an item to a list in a ViewModel using Razor and .NET Core?
So here's my situation. let's say i have a view called theview.cshtml. theview.cshtml has a viewmodel called
Swiftui Mapping Nested JSON to Flat Model
I need to access the data in the nested dictionary of the memodel struct. from both the music and image dictionary. please any help is needed to
What are Android Architecture Components,LiveData and ViewModel?
As a beginner it is very hard to understand what are these things is there any resource which can give a grasp knowledge of things in easy
In AndroidViewModel, how to use the received application property?
A simple androidviewmodel looks like class appviewmodel(application: application) : androidviewmodel(application)
MVC4 View model int property is 1 but HTML rendered to 0?
I have a model property which the controller sets to 1 but in my view i see it as 0 and 1 depending on how i access it. view snippet
ExtJS: Is possible to state if else condition for bind in grid panel?
Inside the viewmodel i've defined 2 stores and i'm using a gridpanel as view. is there any chance to state if else condition for
KO.js model binding. Calling a function in the viewmodel from a grand child is not working
I have the following model binding. <!-- ko foreach: rctapplyvacancy.rctvacancies --> <tr> // some td
Is there a way to pass an argument from NavHostController to ViewModel?
How can i pass an argument from navhostcontroller to my viewmodel init{}?
Ad
Android Architecture Components: Multiple instances of the same view model
I'm new to android architecture components and i have read
what is the correct way of using Models with Partial Views in ASP.NET MVC2?
I'm pretty new to mvc, but now feel pretty comfortable with the pattern, particularly finding viewmodels to be an excellent bridge between
Ad
Blog Categories
Ad