I am building an app in MVVM pattern and I am using 3 different styles of dialogs(some of them have 2 buttons,some of them 3). Since the AlertDialog refers to the view, I wrote the code in the fragment. I have 3 dialogs in the same fragment and its look kind of messy. My questions: Is this a good practice
Tag: mvvm
Why does Retrofit onResponse() is called at last and how can i fix it?
Hello I’m trying to get Weather information by using OpenWeatherAPI. So to connect with OpenWeatherAPI I used Retrofit library. (And also my project is using MVVM Pattern) The problem is that the onResponse() of OpenWeatherRepos is called after the init() of the MainActivityClass is terminated. So OpenWeather is still getting null instances. I don’t know much about API call order
Bind StringProperty to Label from a Singleton
I have a singleton called MenuText. It is responsible for displaying the correct text in the menu. It gets updated dynamically. I have a fxml file, but the MenuText can’t have a reference to it. (This would contradict the MVVM architectural style) Initially I used <fx:define> to setup a reference to the MenuText from the fxml file, but this doesn’t
Class ‘kotlin.reflect.KClass’ is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
After I converted my java code to Kotlin. There is an issue in this code ViewModelContactUs::class.java in this code part java is in red and does not work and says Returns a Java Class instance corresponding to the given KClass instance. Answer I removed this version below from my app/build/gradle file ext.kotlin_version = ‘1.5.0-M1’ I added this version below from
MVVM – where should I call for user location?
currently, I’m building an app which will show for the user recent forecast. For make an api call, I have to provide longitude and latitude as parameter. For now, I have written some code about getting langitude, and longitude, but I don’t receive proper data. As I written those methods in MainActivity, at first, the longitude, and latitude is equal
I’ve received single item from api
I trying to display temperature values that came from the API response in RecyclerView. The thing is my program constantly display just one, first item. I’m not sure where can be the issue, and I feel …
MVVM – get context in a Model class
I’m using MVVM to build my Android app and I need to connect the Model to a DB. Instead of Room I’m using the SQLiteOpenHelper and to make a connection to the DB I need the context. But since this is a non activity class I’m struggling to get it. My current solution looks as follows but I keep getting
Accessing BroadCastReceiver in Viewmodel
I am struggling in choosing the right way to pass data from broadcastReceiver to ViewModel and from there I pass data to my Repository and update LiveData. I use FCM push notifications and have local broadCastReceiver which uses ActivityLifecycle. I found that it is bad practice to access ViewModel from BroadcastReceiver, but not sure why? If I manage lifecycle of
Android MVVM Design Pattern Examples
I currently do a lot of WPF development and have started creating some basic Android apps. When creating WPF apps I often use MVVM, normally using Prism, and would like to know if there are any examples of MVVM for the Android platform? Answer I am the developer of Android-Binding. Like @Brentley said, it’s a very new project but I