Package icyllis.modernui.lifecycle
Class ViewTreeViewModelStoreOwner
java.lang.Object
icyllis.modernui.lifecycle.ViewTreeViewModelStoreOwner
Accessors for finding a view tree-local
ViewModelStoreOwner
that allows access to a
ViewModelStore
for the given view.-
Method Summary
Modifier and TypeMethodDescriptionstatic ViewModelStoreOwner
Retrieve theViewModelStoreOwner
associated with the givenView
.static void
set
(View view, ViewModelStoreOwner viewModelStoreOwner) Set theViewModelStoreOwner
associated with the givenView
.
-
Method Details
-
set
Set theViewModelStoreOwner
associated with the givenView
. Calls toget(View)
from this view or descendants will returnviewModelStoreOwner
.This should only be called by constructs such as activities or fragments that manage a view tree and retain state through a
ViewModelStoreOwner
. Callers should only set aViewModelStoreOwner
that will be stable. The associatedViewModelStore
should be cleared if the view tree is removed and is not guaranteed to later become reattached to a window.- Parameters:
view
- Root view associated with the viewModelStoreOwnerviewModelStoreOwner
- ViewModelStoreOwner associated with the given view
-
get
Retrieve theViewModelStoreOwner
associated with the givenView
. This may be used to retain state associated with this view across configuration changes.- Parameters:
view
- View to fetch aViewModelStoreOwner
for- Returns:
- The
ViewModelStoreOwner
associated with this view and/or some subset of its ancestors
-