Questions tagged [viewmodel]

A view model or viewpoints framework is a framework which defines a coherent set of views to be used in the construction of an architecture. A view is a representation of a whole system from the perspective of a related set of concerns.

Filter by
Sorted by
Tagged with
0 votes
1 answer
19 views

How can I use viewModel with parameters in test

I have a viewmodel to which I inject parameters using Hilt. @HiltViewModel class ShoppingViewModel @Inject constructor( private val addIngredientUseCase: AddIngredientUseCase, private val ...
Martí Curto's user avatar
0 votes
1 answer
26 views

Jetpack Compose not updating without LaunchedEffect of unrelated item

Please can someone throw any light on the problem that I have with Jetpack Compose and a ViewModel. I have a data class called ProductEntity. data class ProductEntity( var id: Int = 0, var ...
eggie's user avatar
  • 13
0 votes
0 answers
28 views

Why does this code stall when trying to listen to the accelerometer sensor after bringing it back into the foreground?

I'm new to mobile development. I've spent the past two weeks trying to learn the Kotlin language and Android app development. I admit I still have no mastery of all the concepts involved, but I ...
Guillermo Davila's user avatar
0 votes
1 answer
58 views

SwiftUI ViewModel keeps init forever

I have the structure like this. import SwiftUI //create a simple view model class ViewModel: NSObject, ObservableObject { @Published var name: String = "World" //create a reference ...
Perry Wang's user avatar
0 votes
0 answers
16 views

Manually clearing the view model in composable Component in Kotlin

I have a common login modal component in my app which is used at many places. This is a composable component( not Destination and i won't be able to convert it to destination). Now what i want that ...
rohit garg's user avatar
0 votes
1 answer
29 views

How to return from a function after callback succeded?

In my viewmodel I have a function which returns a NoDataResult. The function has a callback BleStateCallback. At the moment, as soon as the function is called it returns NoDataFailure(RuntimeException(...
BRDroid's user avatar
  • 4,052
0 votes
1 answer
31 views

Systems.Collections.Generic.List

The model item passed into the ViewDataDictionary is of type 'System.Collections.Generic.List1[CoreApp2.Models.Officer]', but this ViewDataDictionary instance requires a model item of type 'System....
cg1323's user avatar
  • 5
0 votes
0 answers
167 views

Android: Failed to measure fs-verity, errno 1 when updating app from code

I'm trying to add an ability to my android-app to update itself via external link to apk with new version. I'm downloading an apk from external link (I uploaded new build of my app), than I'm using ...
Rostislav Shtanko's user avatar
0 votes
1 answer
29 views

Application maintaining cache even after uninstall

In my application some changes in the code is not reflecting in the application if I re-install the application. It only reflects when I uninstall and install the app again. The device I'm using is ...
Vj sarathi's user avatar
0 votes
1 answer
73 views

Combining two models in one view ASP.NET Core 6 MVC web app with view model only displays data of one model name

I am working on an ASP.NET Core 6 MVC web application. I have created two models (alongside other models which are irrelevant to my question) and each one has their own properties (not going to ...
MYS's user avatar
  • 1
0 votes
0 answers
7 views

Android LiveData re-observed twice when returning to fragment

This is the code from my Fragment: override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) ... viewModel.myLiveData....
F.M.'s user avatar
  • 245
-1 votes
1 answer
52 views

MVVM - Keep Selection after .Clear and new Load the ObservableCollection [closed]

I have an application that pulls a DataTable using a SQL Select and then loads each item into an ObservableCollection for each class. ViewModel: public ObservableCollection<SchachtelEintrag> ...
Julian2005's user avatar
-1 votes
1 answer
82 views

Show a message if the file is opened or closed after a button klick

I have a UserControl and ViewModel and it needs to show a message (TextBlock) after I klick the CheckConfigurationCommand Button. The content of the message depends on the nameFile.config File if it ...
drntvc's user avatar
  • 15
0 votes
0 answers
33 views

Shared ViewModel with MVI architecture

I'm working on an Android application using Jetpack Compose and the MVVM/MVI architecture. I have a BaseViewModel class that all of my ViewModels extend. This class handles the associated State, Event,...
amir's user avatar
  • 1
1 vote
2 answers
61 views

Using Android Jetpack Compose, is it a bad practice to define ViewModel for child composable?

Generally speaking, I know that defining more than a single ViewModel per screen is a bad practice. However for special use cases I found it useful. For instance, let's consider a StatusBar Composable ...
Mirco Bellagamba's user avatar
0 votes
1 answer
56 views

ASP.NET MVC view won't update after model changes

The Radiologists view loads just fine first time you enter, and the dropdown is filled with data. After you select a doctor, the table should display the two values shown in the view, but they won't ...
Diego Perez's user avatar
  • 2,234
0 votes
0 answers
34 views

viewmodel factory class doesn't work: 'create' overrides nothing

im new in Kotlin and im trying to build app with 3 functions, one of them is 'Note' for Note, I've created fragments, database, model, repository, viewmodel but its stuck at view model provider ...
SidPaul 's user avatar
-1 votes
1 answer
45 views

Cannot create an instance of class ViewModel with Room Database in Kotlin

I need to create an application to work with a database. But when creating the model I get an error: Cannot create an instance of class com.example.carexpenses.viewmodels.CarViewModel The error is ...
Utis's user avatar
  • 1
0 votes
1 answer
56 views

Pass Data From One Razor Page to Another Razor Page

I need some assistance please. I have not done this before and I'm not entirely sure what to add where. Basically, I am working on an app to house historical data. There is no create, edit or delete ...
MelB's user avatar
  • 159
2 votes
2 answers
132 views

Unable to Filter Data in ViewModel - Android Kotlin

I am facing issues filtering data in a ViewModel when fetching data from an API. I have a ViewModel (CharacterViewModel) that retrieves data using a getCharactersUseCase. I want to filter this data ...
Zobaer Hossain's user avatar
0 votes
2 answers
55 views

Maui Custom Entry Behavior is blocking blocking Set call on ViewModel

I have created a custom behavior for the Entry control that allows a collection of Entry controls to provide a single-digit code input field that moves the cursor to the next field ( to the right ) ...
Sean Bennington's user avatar
1 vote
1 answer
18 views

How to manage 3 List using live data in recycler view in 3 fragments(ALL List, Recent List, Favorite List) From single room DB table?

The problem i'm facing is whenever i add product in fav list or recent list all fragments observe this change because i'm using single table and cannot put product on top in recent list i want to ...
Rizi's user avatar
  • 11
0 votes
0 answers
31 views

Retrieving ViewModel using SwiftUI and Firebase

I am currently retrieving data from Firebase (a list of stories) but am receiving an error "Type of expression is ambiguous without more context" on the db.collection line of code. It doesn'...
Adam Sewell's user avatar
0 votes
1 answer
46 views

The submit function dosen't display all the data

I have an issue when I submit the data to the ListAdapter, it doesn't show all the data. View Model concept So in my viewmodel I get the data from the firebase to display it. Here is how I approach it,...
Abdelrahman Mahmoud Nasr's user avatar
0 votes
1 answer
31 views

How can I access the viewmodel of a fragment from another fragment?

I am new to Kotlin and am trying to integrate a Room Database. The Main activity holds several fragments, one of the called TestFragment. This Fragment shall list the dao's of a repository and has a ...
Snouty's user avatar
  • 11
0 votes
0 answers
40 views

Android MVVM: How to distribute tasks between UI, ViewModel and repository

I'm writing my first Android App. It's my first Java code either. It's a simple Alarm Clock App. My View is implemented as a Fragment holding a list (RecycleView) of Alarm Items. Each item displays ...
Shaul's user avatar
  • 437
0 votes
0 answers
10 views

How to use viewmodel and I want to use mic functionality code in drffrent class?

Main Activity code public class MainActivity extends AppCompatActivity { FrameLayout z; NavController navController; private SharedViewModel sharedViewModel; private ...
Arshad Siddiqui's user avatar
0 votes
0 answers
33 views

Collecting Data in Repository and ViewModel with Coroutines and Flow

Hello everyone, As part of my work on a caching app, I encountered a situation where I'm returning a Flow<List> from the DAO and have corresponding functions in the repository interface and ...
Tarek Hendi's user avatar
0 votes
0 answers
87 views

Properly initialize a ViewModel and pass it to a Composable - Jetpack compose - Coroutines

I am building an android app using compose and kotlin. I am a beginner and this is my first app. I am facing the following issue: I have a viewModel which is is initialized using the init{} method. ...
DarkBulle's user avatar
  • 149
0 votes
1 answer
36 views

java.lang.RuntimeException: Cannot create an instance of class com.dg.test.analytics.AnalyticsViewModel

Created ViewModel, activity with hilt injections properly. But when i am using viewmodel in composable, its giving this error on runtime @Composable internal fun GalleryPage( analyticsViewModel: ...
shubham chouhan's user avatar
3 votes
2 answers
69 views

Android ViewModel relationship to View without Context

I am having a hard time understanding how to migrate to the Google sanctioned Android modern development. In MVVM the "business logic" should be in the ViewModel, and it is recommended that ...
moonlightcheese's user avatar
0 votes
0 answers
18 views

IValidatableObject does not get its Validate method invoked

I have my viewModel class with a Validate method: public class BookViewModel : IValidatableObject { public IEnumerable<(int AuthorId, string AuthorName)>? Authors { get; set; } public ...
skyhunter96's user avatar
1 vote
0 answers
37 views

How can i share data between navigation subgraph viewmodels in Android using Jetpack compose?

Let`s assume that i have NavHost graph with subgraphs, in one subgraph i have several composables with their "local" route. NavHost( navController = navController, ...
Crystal2033's user avatar
1 vote
2 answers
69 views

ViewModel using Database Room error Android Studio

I'm currently facing an error, where the home fragment and using viewmodel, recyclerview to implement CRUD. the error is where I'm login using id and password in loginfragment, it appears error and ...
Razer's user avatar
  • 45
0 votes
0 answers
62 views

Jetpack Compose: how to save previous data using viewModel+composable

I'm new to jetpack Compose. here is my question: this is the backgroud: I have a Login process to go with two composables, each composalbe is a screen. first screen is to let user input there email ...
郑迎风's user avatar
0 votes
1 answer
76 views

TCP Socket Connection = null when trying to send TCP message

I'm making an Android App that is trying to establish a TCP Connection and outputstream with kotlin Jetpack Compose through a socket by using a function and then send a message using another function ...
afMM's user avatar
  • 3
0 votes
1 answer
40 views

How does my View Model Test class know to use a test data file rather than the normal data file?

Basically, I am fairly new to Android and Kotlin. This is part of the Android Basics with Compose course. The GitHub repo can be found here. I am trying to understand how when I've instantiated a view ...
MrFlavour's user avatar
0 votes
1 answer
37 views

Is passing values from 1 ObservableObject class to another ObservableObject class safe?

My ViewModel is flooded with a ton of values, making it hard to read. I came up with this way to clean up the code. Everything works fine but it is really safe to use? What are the side effects (if ...
Duc Dang's user avatar
  • 186
-1 votes
1 answer
88 views

Swift UI view only displaying one record instead of the List of record

I'm using Swift UI . I'm using async and await to handle the concurrency. I am trying to display list of product record .I have 30 record into json here is the json link https://dummyjson.com/products....
Nus's user avatar
  • 135
0 votes
1 answer
30 views

ArrayList Updating Automatically in ViewModel

I have passed same ArrayList in two method separately and set them two separate ArrayList in ViewModel. When I am updating one (names) ArrayList but another (initialNames) ArrayList also updating. ...
Al-Amin Islam's user avatar
0 votes
0 answers
17 views

How to call a function from multiple activities in Android?

Here is the scenario: I am implementing on-demand feature delivery and The download command is given in the MainActivity, The progress is observed in a BottomSheet If the downloading files for any ...
Waqas Younis's user avatar
0 votes
0 answers
44 views

When I try to send intent to activity was being displayed using app link, new activity is created

My app implements OAuth 2.0 using a custom tab and App Link, and obtains data sent with a redirect URL through App Link through onNewIntent(). I'm trying to send a method to send this data to the ...
PJH's user avatar
  • 110
0 votes
0 answers
38 views

Is there a way to programmatically restart Activity keeping its ViewModel (as if it was a system config change)?

We have an Android device that in addition to a built-in display supports external USB displays, so user can attach a USB touch screen. When that happens we need to move app UI to that newly attached ...
Vit Khudenko's user avatar
  • 28.3k
0 votes
1 answer
56 views

Custom Protocol conformances for ViewModel in swift in MVVM for Input and Output types

I want to create base protocol for Input, Output, and ViewModel for my MVVM architecture. Here is my current implementation for that purpose. I really want to write code-like-that. But the problem is ...
Giga Khizanishvili's user avatar
0 votes
1 answer
50 views

Is this simple ViewModel example to share data between Activities correct?

I'm trying to implement a ViewModel to share data between Activities. Because I am a beginner, the answers I found on the Internet mainly concern fragments and are a little complicated for my current ...
A. Oumnad's user avatar
0 votes
1 answer
41 views

How to create Android ViewModel that gets params?

I'm trying to create the VM class that gets int number as a param, following the updated instruction from the official website: https://developer.android.com/topic/libraries/architecture/viewmodel/...
Vadym Melnychenko's user avatar
0 votes
0 answers
29 views

Stateflow is not getting updated from room database

I am working on a TicTacToe application. I am trying to access the values stored in my CurrScore table. For which I am returning a flow through Dao. I am converting that flow into stateflow in ...
Rahul Arora's user avatar
1 vote
1 answer
53 views

Share viewModel between a composable and an activity

i can inject the same viewmodel in a composable that belongs to ActivityA and an ActivityB but couldn't have the same instance, how can i provide the same instance of the viewmodel using Dagger Hilt ? ...
joghm's user avatar
  • 579
0 votes
0 answers
39 views

(Android Studio) Jetpack Compose ArrayList<String> is resetting in ViewModel

This is a follow-up to my previous issue. I encountered another problem now where ArrayList variables, declared with the syntax by mutableStateOf(), in my ViewModel is resetting after being updated. ...
josephwj's user avatar
0 votes
1 answer
54 views

Maintaining State in foreground service while App is closed

I'm working on a project that interacts with a BLE device. When the app is open, I actively display data transmitted from the device. However, I want to be able to receive data when the app is closed ...
yuz's user avatar
  • 19

1
2 3 4 5
98