added in version 1.1.0
belongs to Maven artifact android.arch.lifecycle:extensions:1.1.1

ViewModelProviders

public class ViewModelProviders
extends Object

java.lang.Object
   ↳ android.arch.lifecycle.ViewModelProviders


Utilities methods for ViewModelStore class.

Summary

Nested classes

class ViewModelProviders.DefaultFactory

This class was deprecated in API level 1.1.0. Use ViewModelProvider.AndroidViewModelFactory  

Public constructors

ViewModelProviders()

This constructor was deprecated in API level 1.1.0. This class should not be directly instantiated

Public methods

static ViewModelProvider of(Fragment fragment)

Creates a ViewModelProvider, which retains ViewModels while a scope of given fragment is alive.

static ViewModelProvider of(FragmentActivity activity)

Creates a ViewModelProvider, which retains ViewModels while a scope of given Activity is alive.

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

Creates a ViewModelProvider, which retains ViewModels while a scope of given fragment is alive.

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

Creates a ViewModelProvider, which retains ViewModels while a scope of given Activity is alive.

Inherited methods

Public constructors

ViewModelProviders

added in version 1.1.0
ViewModelProviders ()

This constructor was deprecated in API level 1.1.0.
This class should not be directly instantiated

Public methods

of

added in version 1.1.0
ViewModelProvider of (Fragment fragment)

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

It uses ViewModelProvider.AndroidViewModelFactory to instantiate new ViewModels.

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

Returns
ViewModelProvider a ViewModelProvider instance

of

added in version 1.1.0
ViewModelProvider of (FragmentActivity activity)

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

It uses ViewModelProvider.AndroidViewModelFactory to instantiate new ViewModels.

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

Returns
ViewModelProvider a ViewModelProvider instance

of

added in version 1.1.0
ViewModelProvider of (Fragment fragment, 
                ViewModelProvider.Factory 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

added in version 1.1.0
ViewModelProvider of (FragmentActivity activity, 
                ViewModelProvider.Factory 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