Skip to content

//workflow/com.squareup.workflow1.ui.backstack/ViewStateCache

ViewStateCache

[androidJvm] @WorkflowUiExperimentalApi()

class ViewStateCache : Parcelable

Handles persistence chores for container views that manage a set of Named renderings, showing a view for one at a time – think back stacks or tab sets.

This class implements Parcelable so that it can be preserved from a container view’s own View.saveHierarchyState method. A simple container can return SavedState from that method rather than creating its own persistence class.

Container views using this class must call attachToParentRegistry and detachFromParentRegistry when they are attached and detached, respectively.

Constructors

ViewStateCache [androidJvm] fun ViewStateCache()

Types

Name Summary
CREATOR [androidJvm]
Content
object CREATOR : Parcelable.Creator<ViewStateCache>


SavedState [androidJvm]
Content
class SavedState : View.BaseSavedState
More info
Convenience for use in View.onSaveInstanceState and View.onRestoreInstanceState methods of container views that have no other state of their own to save.


Functions

Name Summary
attachToParentRegistry [androidJvm]
Content
fun attachToParentRegistry(key: String, parentOwner: SavedStateRegistryOwner)
More info
Must be called whenever the owning view is attached to a window.


describeContents [androidJvm]
Content
open override fun describeContents(): Int


detachFromParentRegistry [androidJvm]
Content
fun detachFromParentRegistry()
More info
Must be called whenever the owning view is detached from a window.


prune [androidJvm]
Content
fun prune(retaining: Collection<Named<*>>)
More info
To be called when the set of hidden views changes but the visible view remains the same.


restore [androidJvm]
Content
fun restore(from: ViewStateCache)
More info
Replaces the state of the receiver with that of from.


update [androidJvm]
Content
fun update(retainedRenderings: Collection<Named<*>>, oldViewMaybe: View?, newView: View)


writeToParcel [androidJvm]
Content
open override fun writeToParcel(parcel: Parcel, flags: Int)