viewmodel

MVVM - Accessing ViewModel/SQLite in a BroadcastReceiver started from a notification when app is closed

。_饼干妹妹 提交于 2021-02-07 14:15:36
问题 I have a reminder notification that is sent every few days. The sending of that notification is triggered with a repeating AlarmManager . The notification itself is built in the onReceive of my BroadcastReceiver (as described here). So when onReceive is triggered, the app is not even open/running. Now at that point I want to access my (local) SQLite database and get the correct content to build the notification with, but how would I get a ViewModelProvider (xxx in the code) in this place to

MVVM - Accessing ViewModel/SQLite in a BroadcastReceiver started from a notification when app is closed

╄→尐↘猪︶ㄣ 提交于 2021-02-07 14:13:15
问题 I have a reminder notification that is sent every few days. The sending of that notification is triggered with a repeating AlarmManager . The notification itself is built in the onReceive of my BroadcastReceiver (as described here). So when onReceive is triggered, the app is not even open/running. Now at that point I want to access my (local) SQLite database and get the correct content to build the notification with, but how would I get a ViewModelProvider (xxx in the code) in this place to

MVVM - Accessing ViewModel/SQLite in a BroadcastReceiver started from a notification when app is closed

↘锁芯ラ 提交于 2021-02-07 14:12:40
问题 I have a reminder notification that is sent every few days. The sending of that notification is triggered with a repeating AlarmManager . The notification itself is built in the onReceive of my BroadcastReceiver (as described here). So when onReceive is triggered, the app is not even open/running. Now at that point I want to access my (local) SQLite database and get the correct content to build the notification with, but how would I get a ViewModelProvider (xxx in the code) in this place to

How to properly reload liveData manually in Android?

大城市里の小女人 提交于 2021-02-07 04:01:46
问题 My app is a basic news app which fetches data from JSON provided by Guardian API. I parsed the values from JSON using raw java code (not using retrofit). Then I get the LiveData in NewsFeedViewModel class which extends as AndroidViewModel. And then in the fragment, I submit list to adapter. These are the issues I'm facing: 1) at first, if the articles to show is set to 10, then if i go to settings and change it to 2, then the last 8 articles are disappearing but the white space /gap is not

View to different view model binding in Xamarin forms

我与影子孤独终老i 提交于 2021-02-05 12:01:20
问题 I am having 2 views in my application and each of them having associated view model .I am having a requirement like access the second viewmodel methods form the first view's xaml.cs file (I don't want to bring all the logic in second viewmodel to first one ,that's why keeping both view model as such ) Is there any way i can achieve the same ? 回答1: You can do that by making a ViewModelLocator using MVVMLight, it will create a singleton pattern and you can access ViewModel anywhere using

Multiple ViewModels in same View

非 Y 不嫁゛ 提交于 2021-01-29 22:05:19
问题 I have several different ViewModels that I would like to display in the same view (MainPage.xaml). I'm new to this and don't know how to do it. I have tried to create a MainViewModel: public class MainViewModel : ViewModelBase, INotifyPropertyChanged { WeatherViewModel weatherView = new WeatherViewModel(); ForecastViewModel forecastViewModel = new ForecastViewModel(); DeparturesViewModel departuresViewModel = new DeparturesViewModel(); CalenderViewModel calenderViewModel = new

Many instances of ViewModel, how to fix it?

大憨熊 提交于 2021-01-29 11:19:25
问题 I made ViewModelFactory by this example: public class ViewModelFactory extends ViewModelProvider.NewInstanceFactory { @SuppressLint("StaticFieldLeak") private static volatile ViewModelFactory INSTANCE; private final Application application; public static ViewModelFactory getInstance(Application application) { if (INSTANCE == null) { synchronized (ViewModelFactory.class) { if (INSTANCE == null) { INSTANCE = new ViewModelFactory(application); } } } return INSTANCE; } private ViewModelFactory

list is not getting in recyclerview using retrofit

Deadly 提交于 2021-01-29 10:48:33
问题 basically im trying display list in recyclerview using retrofit and viewmodel........ on debugging the onresponse im getting 200 response but why is it not displaying list in recyclerview i dont know where im going wrong i will post up more codes if needed following is the code:--- class Tables : BaseClassActivity() { lateinit var recyclerView: RecyclerView lateinit var recyclerAdapter: TableAdapter var Tablelist : MutableList<Tabledata> = mutableListOf() override fun onCreate

Cannot create an instance of class ViewModel in Android MVVM

喜你入骨 提交于 2021-01-29 04:53:55
问题 I am learning android MVVM pattern android development. I wanted to create a recycclerview activity to show data from server. But it's not accepting my viewmodel class. Bellow is my logcat errors. LOGCAT 2020-04-12 21:03:18.026 2008-2008/com.shovon.mvvm E/AndroidRuntime: FATAL EXCEPTION: main Process: com.shovon.mvvm, PID: 2008 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shovon.mvvm/com.shovon.mvvm.activity.RecyclerActivity}: java.lang.RuntimeException: Cannot

Cannot create an instance of class ViewModel in Android MVVM

眉间皱痕 提交于 2021-01-29 04:53:53
问题 I am learning android MVVM pattern android development. I wanted to create a recycclerview activity to show data from server. But it's not accepting my viewmodel class. Bellow is my logcat errors. LOGCAT 2020-04-12 21:03:18.026 2008-2008/com.shovon.mvvm E/AndroidRuntime: FATAL EXCEPTION: main Process: com.shovon.mvvm, PID: 2008 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shovon.mvvm/com.shovon.mvvm.activity.RecyclerActivity}: java.lang.RuntimeException: Cannot