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 ViewModelStoreOwnerRetrieve theViewModelStoreOwnerassociated with the givenView.static voidset(View view, ViewModelStoreOwner viewModelStoreOwner) Set theViewModelStoreOwnerassociated with the givenView.
-
Method Details
-
set
Set theViewModelStoreOwnerassociated 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 aViewModelStoreOwnerthat will be stable. The associatedViewModelStoreshould 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 theViewModelStoreOwnerassociated with the givenView. This may be used to retain state associated with this view across configuration changes.- Parameters:
view- View to fetch aViewModelStoreOwnerfor- Returns:
- The
ViewModelStoreOwnerassociated with this view and/or some subset of its ancestors
-