ViewModelProviders

public class ViewModelProviders
extends Object

java.lang.Object
   ↳ androidx.lifecycle.ViewModelProviders


This class is deprecated.
Use the constructors for ViewModelProvider directly.

Utilities methods for ViewModelStore class.

Summary

Nested classes

class ViewModelProviders.DefaultFactory

This class is deprecated. Use ViewModelProvider.AndroidViewModelFactory  

Public constructors

ViewModelProviders()

This constructor is deprecated. This class should not be directly instantiated

Public methods

static ViewModelProvider of(Fragment fragment, ViewModelProvider.Factory factory)

This method is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner, Factory), passing in the fragment and factory.

static ViewModelProvider of(Fragment fragment)

This method is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner), passing in the fragment.

static ViewModelProvider of(FragmentActivity activity, ViewModelProvider.Factory factory)

This method is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner, Factory), passing in the activity and factory.

static ViewModelProvider of(FragmentActivity activity)

This method is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner), passing in the activity.

Inherited methods

Public constructors

ViewModelProviders

public ViewModelProviders ()

This constructor is deprecated.
This class should not be directly instantiated

Public methods

of

public static ViewModelProvider of (Fragment fragment, 
                ViewModelProvider.Factory factory)

This method is deprecated.
Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner, Factory), passing in the fragment and factory.

Creates a ViewModelProvider, which retains ViewModels while a scope of given fragment is alive. More detailed explanation is in ViewModel.

It uses the given ViewModelProvider.Factory to instantiate new ViewModels.

Parameters
fragment Fragment: a fragment, in whose scope ViewModels should be retained

factory ViewModelProvider.Factory: a Factory to instantiate new ViewModels

Returns
ViewModelProvider a ViewModelProvider instance

of

public static ViewModelProvider of (Fragment fragment)

This method is deprecated.
Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner), passing in the fragment.

Creates a ViewModelProvider, which retains ViewModels while a scope of given fragment is alive. More detailed explanation is in ViewModel.

It uses the default factory to instantiate new ViewModels.

Parameters
fragment Fragment: a fragment, in whose scope ViewModels should be retained

Returns
ViewModelProvider a ViewModelProvider instance

of

public static ViewModelProvider of (FragmentActivity activity, 
                ViewModelProvider.Factory factory)

This method is deprecated.
Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner, Factory), passing in the activity and factory.

Creates a ViewModelProvider, which retains ViewModels while a scope of given Activity is alive. More detailed explanation is in ViewModel.

It uses the given ViewModelProvider.Factory to instantiate new ViewModels.

Parameters
activity FragmentActivity: an activity, in whose scope ViewModels should be retained

factory ViewModelProvider.Factory: a Factory to instantiate new ViewModels

Returns
ViewModelProvider a ViewModelProvider instance

of

public static ViewModelProvider of (FragmentActivity activity)

This method is deprecated.
Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider.ViewModelProvider(ViewModelStoreOwner), passing in the activity.

Creates a ViewModelProvider, which retains ViewModels while a scope of given Activity is alive. More detailed explanation is in ViewModel.

It uses the default factory to instantiate new ViewModels.

Parameters
activity FragmentActivity: an activity, in whose scope ViewModels should be retained

Returns
ViewModelProvider a ViewModelProvider instance