Skip to main content
Filter by
Sorted by
Tagged with
4 votes
2 answers
137 views

How to use Dispatchers.IO correctly to read local files on Android?

In the Android documentation it says the following: Dispatchers.IO - This dispatcher is optimized to perform disk or network I/O outside of the main thread. Examples include using the Room component, ...
A. Cedano's user avatar
  • 879
1 vote
1 answer
114 views

How to drag and reorder list in Jetpack Compose?

Can someone help me correct the logic of reordering list. I believe the moveTodo function in viewmodel is not working properly. Reordering is working but not like how it should. Project Structure ..db ...
Harsh Vardhan's user avatar
0 votes
0 answers
56 views

How to share Saved State Handle to another view models?

I'm working on an Android application where I have a shared ViewModel that utilizes SavedStateHandle. I want to know if it's possible to create sub ViewModels in different screens (composables) using ...
serkancay's user avatar
  • 185
2 votes
1 answer
177 views

multiple instances with compose and kotlin

sorry for the English, I'm using a translator.i'm just a beginner, please consider this when replying.i know the code may not be the best. this is just a start. I'm using the viewmodel to create a ...
Ramon Xavier's user avatar
0 votes
2 answers
67 views

Optional multi-value filtering function for Room Database Compose/Kotlin

So, I've got a database collection thing I am working on. The main view is just a list of all the stuff in the database, and I'm currently trying to add optional filtering by certain parameters. I ...
sardonicus87's user avatar
0 votes
1 answer
77 views

Android Compose MVVM File Picker Can See File, Cannot Select (Import CSV), permissions, other issues SKD 30+

I've searched everywhere and I can't find any answers that make any sense, and every answer I tried I could find, causes the app to crash instantly. I even got desperate and asked Gemini for help, ...
sardonicus87's user avatar
1 vote
1 answer
87 views

Best way to use ArrayList in in Kotlin/MVVM. StateFlow vs Flow vs suspend

I am trying to upgrade my java code to kotlin but I don't know how to aproach this transition. It seems that I have to perfectly understand corutines which is a pain because it seems too much all at ...
Chris's user avatar
  • 127
1 vote
2 answers
89 views

Why network call is not triggered while using retrofit with jetpack compose mvvvm

I have an endpoint https://api.openweathermap.org/data/2.5/weather?q=sukkur,pk&appid=5*****************c I want to use retrofit to make call to this end point interface WeatherApiService { @...
Arshad Ali's user avatar
  • 3,254
1 vote
2 answers
278 views

How to pass a String parameter to a viewmodel in compose?

How can I pass a String parameter to a ViewModel in Compose? I mean a string variable, not a hardcoded one or an Application stored one. I need to pass it as a parameter. This is just for learning ...
NullPointerException's user avatar
0 votes
0 answers
104 views

Kotlin - videos not playing when there is no internet connection (offline)

I have tried with different cases, videos not playing when there is no internet connection. I have debugged it, path is coming fine. FilePath: /storage/emulated/0/Android/data/com.android.XXXXX/files/...
Naveen's user avatar
  • 973
0 votes
2 answers
534 views

Kotlin, cannot create instance of class Viewmodel

I am new to MVVM architecture, I have tried with different options but still getting same exception "cannot able to create an instance ViewModel". I am using Android Studio Iguana below is ...
Naveen's user avatar
  • 973
0 votes
1 answer
114 views

Trouble Injecting ViewModel with Hilt in Android Kotlin App

I'm working on an Android app using Kotlin, Jetpack Compose, and Hilt for dependency injection. Despite following the recommended setup for Hilt, I keep encountering a runtime exception when trying to ...
Diadem's user avatar
  • 461
0 votes
0 answers
60 views

Android Kotlin ViewModel is not Loading/Showing content at first launch of the fragment/activity

I have a Android Kotlin MVVM project, ViewModel is not being loaded at first lauch of the Fragment. But if i refresh it load data and show in the UI HomeFragment.kt UI class HomeFragment : Fragment() {...
Andongwisye Mwamengo's user avatar
0 votes
0 answers
83 views

Not receiving events from Event flow in android

I'm using MVVM architecture along with dagger hilt. I'm using event channel to send my events then retrieve them using event flow like shown below. I wanted to test everything by just ticking or ...
TerminalKid's user avatar
0 votes
0 answers
159 views

MVVM Usecase Repository Architecture with Base Classes: Best Practices and Clean Architecture Compliance

I am trying to implement the MVVM usecase repository architecture in my Jetpack Compose project. I use a sealed class called Resource to manage service requests: sealed class Resource<out T : Any?&...
Heisenberg's user avatar
1 vote
0 answers
70 views

Idea needed: How to make viewmodel state - drag&drop in compose list that can be edited

I have a very simple list on the screen. Data goes from viewmodel state from database as observable flow (very ordinary case) List item is very simple: it has id, name, order_ (the order of item in ...
Foenix's user avatar
  • 538
0 votes
0 answers
60 views

retrieve a single value from room entity using viewmodel

I am trying to implement favoriting feature in my application using room db. I am storing the data from an API call and present it using the ViewModel and MutableLiveData. The problem I going through ...
Unish Raj.'s user avatar
1 vote
1 answer
616 views

Android Clean Architecture View Model implements callbacks from View

I was just dealing with clean architecture in Android apps and MVVM. I heard that you shouldn't pass your ViewModel directly to the screen (I use Jetpack Compose) but rather its states and every ...
JokerGrAp's user avatar
7 votes
1 answer
1k views

Android Compose Paging 3 - Loading all pages at once without scrolling in LazyColumn with network call and no inner scrolls

I'm working on an Android Compose project where I'm using Paging 3 along with a LazyColumn to display a list of items fetched from a network call. The default behavior of Paging 3 is to load pages ...
Kartheek's user avatar
  • 7,194
0 votes
1 answer
170 views

Call Multiple ViewModel Functions in a Screen vs Single ViewModel Function

Say in the OrderScreen, we have OrderViewModel(orderRepository) and UserViewModel(userRepository). Approach #1: class OrderViewModel(private val orderRepository: OrderRepository) : ViewModel() { ...
Sam Chen's user avatar
  • 8,765
0 votes
0 answers
80 views

Andorid Jetpack Compose State not Updating

I am working on a Jet Shopping App using Room DB with reference from HOODLAB youtube video & my full code is build without error. Problems: When I am adding an item to the list, it is not showing....
Kaushalendra Singh's user avatar
0 votes
3 answers
42 views

LiveData observer triggering previous response

In my login page when I click on login button with valid email and password, then it goes into homepage. and then when i logged out from there and redirect to login page . then i face is when i clicks ...
Asikur Rahman's user avatar
1 vote
1 answer
294 views

Update the count value in Column Item Android Jetpack Compose

Product Item Composable : @Composable fun ProductItem(product: Product, index: Int) { val addProductViewModel = hiltViewModel<AddProductVM>() val productSelectedIndex = remember { ...
SasidharanIOS's user avatar
1 vote
2 answers
984 views

How to create singleton object and using for UI and viewmodel for two screen in kotlin jetpack compose?

I have a list like this data class SelectedNtrItem( val items:ArrayList<NutritionSearchItem> = arrayListOf() ) I need to use this list on two composable screens, so I need to ...
NewPartizal's user avatar
  • 1,094
0 votes
2 answers
74 views

How to make ViewModels communicate with same Model if I shouldn't in MVVM create Model in View?

Say, I have two Views. One is button, second is textView. When I click button, something changes in text. If I make it in MVVM, probably it should look like this: There are button and text view which ...
Helkor's user avatar
  • 41
0 votes
2 answers
511 views

How to implement RoomDataBase in An Activity using Dagger Hilt Injection in View Model

I'm trying to make an app that can enter and store Bible Verses. I'm using Dagger Hilt to inject my Daos into my View Model . My App keeps crashing whenever I try to use viewModel to get my state and ...
TerminalKid's user avatar
-1 votes
1 answer
192 views

Android: Model mapping in repository pattern

I want to fetch news from remote and map network response to entity class to store in room database in repository layer. i am using separate data class for both remote and database Here are the data ...
Techchai Mobile's user avatar
0 votes
3 answers
2k views

"Using ViewModel and LiveData Without Explicit Dependency Declaration in build.gradle"

I've noticed that in some of my Android projects, I'm able to access ViewModel and LiveData classes without explicitly adding the following dependencies to my build.gradle file: implementation("...
Eeman's user avatar
  • 175
0 votes
1 answer
63 views

How to get appModule properties in feature modules

My project is having feature1Module and feature2Module. These 2 are included in app module build gradle file. implementation project(":feature1Module") implementation project(":...
G Anil Reddy's user avatar
0 votes
0 answers
48 views

MVVM Architecture Screen Rotation Issues

I have been trying to make a simple program where I will get data from Retrofit API calling into RecyclerView using MVVM architecture with JAVA, but I am not getting any data from Retrofit API into ...
Himanshu Satone's user avatar
0 votes
1 answer
83 views

Why Kotlin's collect function doesn't terminate itself?

When I download info from a DataBase the collect function doesn’t stop emission (Kotlin's collect function doesn't terminate itself.) I have this entity class: @Entity data class ShareEntity( @...
Евгений s's user avatar
0 votes
0 answers
124 views

Two use cases which access the same repository - how to avoid identical/ duplicate API calls?

I have two use cases UseCase A and UseCase B which access the same repository Repo X. Repo X makes a API (data.com/getUserInfo) call to get certain data. ViewModel 1 has need for only UseCase B, while ...
kk_1807's user avatar
  • 11
3 votes
2 answers
3k views

Navigate using View Model in Jetpack Compose

Here is my MainActivity.kt file Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { NavigationHoster() } here is navhoster ...
Gayantha's user avatar
  • 438
0 votes
1 answer
80 views

I want to store and display highScore value on local device with .NET MAUI MVVM. Where and with what code snippet can I do this?

I'm developing a simple math practice game with .NET MAUI MVVM. I want the highScore value on the main page of the game to be updated after I close the application and re-enter it every time I play. ...
M3rtixius's user avatar
-1 votes
1 answer
85 views

The score I earned on the Game page with .NET MAUI MVVM is not visible on other pages. How can I keep score data in Local device

I want to display the score information I earned on the MultiplicationPage on the GameOverPage. I think I pulled the data from PlayerModal but it still doesn't show up. GameOverPage.xaml <?xml ...
M3rtixius's user avatar
0 votes
1 answer
66 views

Whether the answer is right or wrong, my score and counter are constantly increasing. Idont want this

Using the MVVM Design Pattern I am developing a basic operations math application.When I give a wrong answer, my score and counter score increase as if I answered correctly. I used some artificial ...
M3rtixius's user avatar
0 votes
1 answer
121 views

I made the property observable but it is not visible on the screen

In this application that I developed with MVVM, counter, question, score and answer were displayed on the screen before adding the Observable feature. When I added the Observable feature, these ...
M3rtixius's user avatar
0 votes
1 answer
109 views

Time, score and questions do not appear on the screen with .NET MAUI MVVM

MultiplicationPage.xaml <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="...
M3rtixius's user avatar
0 votes
1 answer
68 views

Clicking the Play button on the HomePage does not go to the GameSelectionPage

MauiProgram.cs using MauiApp1.Sevices; using MauiApp1.ViewModels; using MauiApp1.Views; using Microsoft.Extensions.Logging; namespace MauiApp1; public static class MauiProgram { public static ...
M3rtixius's user avatar
0 votes
1 answer
714 views

Not able to access SavedStateHandle from @Hilt ViewModel

I have two fragments, and I want to access the todoId from the ViewModel of the second fragment, but I am encountering issues while trying to access it. Here is the problem I am facing: E/...
Ashif Ali's user avatar
0 votes
1 answer
64 views

How to update value every x seconds or when value from room database is changes

I'd like the variable listOfPoints to change every time when workout.points is changed or every "x" seconds. var listOfPoints = emptyList<LatLng>() var workoutId = viewModel....
xMaster's user avatar
  • 41
1 vote
1 answer
1k views

How can I call multiple APIs that are depending to each other's data, each response data must be used on the following API call?

//From Kotlin code (Compose View), using CoroutineScope scope.launch { viewModel.getDataOne(key) viewModel.data_one.collect{ one -> when(one){ is DataState.Success->{ ...
Lloyd Munyai's user avatar
0 votes
1 answer
2k views

The communication between: A view, A viewModel, A useCase, A repository, A service, and A dao in a clean architecture (MVVM) for Android

Using the monarchy realm database, a dao gives liveData. A repository gives that liveData to a useCase as a flow using .asFlow on the liveData. The useCase needs to return the flow to a ViewModel ...
Sagar Patel's user avatar
0 votes
1 answer
2k views

How to test the ViewModel using Junit, Mockito and Kotlin flows in Android

I tried to test the ViewModel using Junit and Mockito, getting null pointer exception. It returns cannot invoke flow collector. I want to test the responses coming in MpinDataKey, check all parameters ...
Cijo K Paul's user avatar
0 votes
1 answer
395 views

error: cannot find symbol import com.example.databinding2.databinding.ActivityMainBindingImpl;

I'm unable to resolve this error. I wanted to use two-way databinding in edittext. Here is the code for the layout file. <?xml version="1.0" encoding="utf-8"?> <layout ...
Anmol Agrawal's user avatar
0 votes
1 answer
689 views

Serialise json string with dynamic key to object in Kotlin

I am working on a requirement, where as when making a service call to the API, if it is success, the response object will be a set of key-value in the following format: string : {string: string} For ...
Long Dao's user avatar
  • 1,371
0 votes
1 answer
23 views

How to update UI from recyclerview custom listener class onScrollStateChanged?

My CustomScroll Listener class is . This is separate class class CustomScrollListener(): RecyclerView.OnScrollListener(){ override fun onScrollStateChanged(recyclerView: RecyclerView, newState: ...
Karthik . N's user avatar
0 votes
1 answer
141 views

Where to place the MyFirebaseMessagingService file in Android project MVVM?

I have an Android project where I use MVVM. This is the structure: src \_ domain \_ model \_ repository \_ ItemsRepository \_ data \_ repository \_ ...
Always Learner's user avatar
2 votes
2 answers
3k views

Jetpack Compose: How good is having a separate ViewModel for every interactive component on Screen

I have chat like interface in Jetpack compose. Every message can either be Text, Audio, Video, or Image. Each Audio message is displayed with the help of a AudioPlayer composable, and an attached ...
thedroiddiv's user avatar
1 vote
1 answer
775 views

Database_Impl not implemented - MVVM Room Kotlin Android

I'm new here, grateful to meet you all here. I have an error like this based on my Logcat. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.voidcreativestation.toko/com....
K La's user avatar
  • 11

1
2 3 4 5
16