ViewModelProviders
-
android
class ViewModelProviders
Utilities methods for ViewModelStore class.
Summary
Nested types |
|---|
|
This class is deprecated. Use ViewModelProvider.AndroidViewModelFactory |
Public constructors |
|
|---|---|
|
This function is deprecated. This class should not be directly instantiated |
android
|
Public functions |
||
|---|---|---|
java-static ViewModelProvider |
@MainThreadThis function is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider, passing in the activity. |
android
|
java-static ViewModelProvider |
@MainThreadThis function is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider, passing in the fragment. |
android
|
java-static ViewModelProvider |
@MainThreadThis function is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider, passing in the activity and factory. |
android
|
java-static ViewModelProvider |
@MainThreadThis function is deprecated. Use the 'by viewModels()' Kotlin property delegate or ViewModelProvider, passing in the fragment and factory. |
android
|
Public constructors
Public functions
of
@MainThread
java-static funof(activity: FragmentActivity): ViewModelProvider
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 |
of
@MainThread
java-static funof(fragment: Fragment): ViewModelProvider
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
@MainThread
java-static funof(activity: FragmentActivity, factory: ViewModelProvider.Factory?): ViewModelProvider
Creates a ViewModelProvider, which retains ViewModels while a scope of given Activity is alive. More detailed explanation is in ViewModel.
It uses the given Factory to instantiate new ViewModels.
| Parameters | |
|---|---|
activity: FragmentActivity |
an activity, in whose scope ViewModels should be retained |
factory: ViewModelProvider.Factory? |
a |
| Returns | |
|---|---|
ViewModelProvider |
a ViewModelProvider instance |
of
@MainThread
java-static funof(fragment: Fragment, factory: ViewModelProvider.Factory?): ViewModelProvider
Creates a ViewModelProvider, which retains ViewModels while a scope of given fragment is alive. More detailed explanation is in ViewModel.
It uses the given Factory to instantiate new ViewModels.
| Parameters | |
|---|---|
fragment: Fragment |
a fragment, in whose scope ViewModels should be retained |
factory: ViewModelProvider.Factory? |
a |
| Returns | |
|---|---|
ViewModelProvider |
a ViewModelProvider instance |