AbstractSavedStateViewModelFactory
public
abstract
class
AbstractSavedStateViewModelFactory
extends Object
implements
ViewModelProvider.Factory
java.lang.Object
|
↳ |
androidx.lifecycle.AbstractSavedStateViewModelFactory
|
Known direct subclasses
HiltViewModelFactory |
This class is deprecated.
References to this type and bindings to it should be removed. An equivalent factory
to this is now provided out of the box by Hilt.
|
|
Skeleton of androidx.lifecycle.ViewModelProvider.KeyedFactory
that creates SavedStateHandle
for every requested ViewModel
.
The subclasses implement create(String, Class, SavedStateHandle)
to actually instantiate
androidx.lifecycle.ViewModel
s.
Summary
Public methods |
abstract
<T extends ViewModel>
T
|
create(String key, Class<T> modelClass)
Creates a new instance of the given Class .
|
final
<T extends ViewModel>
T
|
create(Class<T> modelClass)
Creates a new instance of the given Class .
|
Protected methods |
abstract
<T extends ViewModel>
T
|
create(String key, Class<T> modelClass, SavedStateHandle handle)
Creates a new instance of the given Class .
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
|
Public constructors
AbstractSavedStateViewModelFactory
public AbstractSavedStateViewModelFactory (SavedStateRegistryOwner owner,
Bundle defaultArgs)
Constructs this factory.
Parameters |
owner |
SavedStateRegistryOwner : SavedStateRegistryOwner that will provide restored state for created
ViewModels |
defaultArgs |
Bundle : values from this Bundle will be used as defaults by
SavedStateHandle passed in ViewModels
if there is no previously saved state
or previously saved state misses a value by such key
|
Public methods
create
public abstract T create (String key,
Class<T> modelClass)
Creates a new instance of the given Class
.
Parameters |
key |
String : a key associated with the requested ViewModel |
modelClass |
Class : a Class whose instance is requested |
Returns |
T |
a newly created ViewModel
|
create
public final T create (Class<T> modelClass)
Creates a new instance of the given Class
.
Parameters |
modelClass |
Class : a Class whose instance is requested |
Returns |
T |
a newly created ViewModel
|
Protected methods
create
protected abstract T create (String key,
Class<T> modelClass,
SavedStateHandle handle)
Creates a new instance of the given Class
.
Parameters |
key |
String : a key associated with the requested ViewModel |
modelClass |
Class : a Class whose instance is requested |
handle |
SavedStateHandle : a handle to saved state associated with the requested ViewModel |
Returns |
T |
a newly created ViewModels
|