Search in sources :

Example 1 with ViewModelProviderFactory

use of com.mindorks.framework.mvvm.ViewModelProviderFactory in project android-mvvm-architecture by MindorksOpenSource.

the class ActivityModule method provideFeedViewModel.

@Provides
FeedViewModel provideFeedViewModel(DataManager dataManager, SchedulerProvider schedulerProvider) {
    Supplier<FeedViewModel> supplier = () -> new FeedViewModel(dataManager, schedulerProvider);
    ViewModelProviderFactory<FeedViewModel> factory = new ViewModelProviderFactory<>(FeedViewModel.class, supplier);
    return new ViewModelProvider(activity, factory).get(FeedViewModel.class);
}
Also used : FeedViewModel(com.mindorks.framework.mvvm.ui.feed.FeedViewModel) ViewModelProviderFactory(com.mindorks.framework.mvvm.ViewModelProviderFactory) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Provides(dagger.Provides)

Example 2 with ViewModelProviderFactory

use of com.mindorks.framework.mvvm.ViewModelProviderFactory in project android-mvvm-architecture by MindorksOpenSource.

the class FragmentModule method provideBlogViewModel.

@Provides
BlogViewModel provideBlogViewModel(DataManager dataManager, SchedulerProvider schedulerProvider) {
    Supplier<BlogViewModel> supplier = () -> new BlogViewModel(dataManager, schedulerProvider);
    ViewModelProviderFactory<BlogViewModel> factory = new ViewModelProviderFactory<>(BlogViewModel.class, supplier);
    return new ViewModelProvider(fragment, factory).get(BlogViewModel.class);
}
Also used : ViewModelProviderFactory(com.mindorks.framework.mvvm.ViewModelProviderFactory) BlogViewModel(com.mindorks.framework.mvvm.ui.feed.blogs.BlogViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Provides(dagger.Provides)

Example 3 with ViewModelProviderFactory

use of com.mindorks.framework.mvvm.ViewModelProviderFactory in project android-mvvm-architecture by MindorksOpenSource.

the class FragmentModule method provideAboutViewModel.

@Provides
AboutViewModel provideAboutViewModel(DataManager dataManager, SchedulerProvider schedulerProvider) {
    Supplier<AboutViewModel> supplier = () -> new AboutViewModel(dataManager, schedulerProvider);
    ViewModelProviderFactory<AboutViewModel> factory = new ViewModelProviderFactory<>(AboutViewModel.class, supplier);
    return new ViewModelProvider(fragment, factory).get(AboutViewModel.class);
}
Also used : ViewModelProviderFactory(com.mindorks.framework.mvvm.ViewModelProviderFactory) AboutViewModel(com.mindorks.framework.mvvm.ui.about.AboutViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Provides(dagger.Provides)

Example 4 with ViewModelProviderFactory

use of com.mindorks.framework.mvvm.ViewModelProviderFactory in project android-mvvm-architecture by MindorksOpenSource.

the class ActivityModule method provideSplashViewModel.

@Provides
SplashViewModel provideSplashViewModel(DataManager dataManager, SchedulerProvider schedulerProvider) {
    Supplier<SplashViewModel> supplier = () -> new SplashViewModel(dataManager, schedulerProvider);
    ViewModelProviderFactory<SplashViewModel> factory = new ViewModelProviderFactory<>(SplashViewModel.class, supplier);
    return new ViewModelProvider(activity, factory).get(SplashViewModel.class);
}
Also used : ViewModelProviderFactory(com.mindorks.framework.mvvm.ViewModelProviderFactory) SplashViewModel(com.mindorks.framework.mvvm.ui.splash.SplashViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Provides(dagger.Provides)

Example 5 with ViewModelProviderFactory

use of com.mindorks.framework.mvvm.ViewModelProviderFactory in project android-mvvm-architecture by MindorksOpenSource.

the class ActivityModule method provideMainViewModel.

@Provides
MainViewModel provideMainViewModel(DataManager dataManager, SchedulerProvider schedulerProvider) {
    Supplier<MainViewModel> supplier = () -> new MainViewModel(dataManager, schedulerProvider);
    ViewModelProviderFactory<MainViewModel> factory = new ViewModelProviderFactory<>(MainViewModel.class, supplier);
    return new ViewModelProvider(activity, factory).get(MainViewModel.class);
}
Also used : ViewModelProviderFactory(com.mindorks.framework.mvvm.ViewModelProviderFactory) MainViewModel(com.mindorks.framework.mvvm.ui.main.MainViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Provides(dagger.Provides)

Aggregations

ViewModelProvider (androidx.lifecycle.ViewModelProvider)8 ViewModelProviderFactory (com.mindorks.framework.mvvm.ViewModelProviderFactory)8 Provides (dagger.Provides)8 AboutViewModel (com.mindorks.framework.mvvm.ui.about.AboutViewModel)1 FeedViewModel (com.mindorks.framework.mvvm.ui.feed.FeedViewModel)1 BlogViewModel (com.mindorks.framework.mvvm.ui.feed.blogs.BlogViewModel)1 OpenSourceViewModel (com.mindorks.framework.mvvm.ui.feed.opensource.OpenSourceViewModel)1 LoginViewModel (com.mindorks.framework.mvvm.ui.login.LoginViewModel)1 MainViewModel (com.mindorks.framework.mvvm.ui.main.MainViewModel)1 RateUsViewModel (com.mindorks.framework.mvvm.ui.main.rating.RateUsViewModel)1 SplashViewModel (com.mindorks.framework.mvvm.ui.splash.SplashViewModel)1