SavedStateRegistryController


public final class SavedStateRegistryController


An API for SavedStateRegistryOwner implementations to control SavedStateRegistry.

SavedStateRegistryOwner should call performRestore to restore state of SavedStateRegistry and performSave to gather SavedState from it.

Summary

Public methods

static final @NonNull SavedStateRegistryController

Creates a SavedStateRegistryController.

final @NonNull SavedStateRegistry

The SavedStateRegistry owned by this controller

final void

Perform the initial, one time attachment necessary to configure this SavedStateRegistry.

final void

An interface for an owner of this SavedStateRegistry to restore saved state.

final void

An interface for an owner of this SavedStateRegistry to perform state saving, it will call all registered providers and merge with unconsumed state.

Public methods

create

Added in 1.2.0
public static final @NonNull SavedStateRegistryController create(@NonNull SavedStateRegistryOwner owner)

Creates a SavedStateRegistryController.

It should be called during construction time of SavedStateRegistryOwner

getSavedStateRegistry

Added in 1.0.0
public final @NonNull SavedStateRegistry getSavedStateRegistry()

The SavedStateRegistry owned by this controller

performAttach

Added in 1.2.0
@MainThread
public final void performAttach()

Perform the initial, one time attachment necessary to configure this SavedStateRegistry. This must be called when the owner's Lifecycle is Lifecycle.State.INITIALIZED and before you call performRestore.

performRestore

@MainThread
public final void performRestore(SavedState savedState)

An interface for an owner of this SavedStateRegistry to restore saved state.

Parameters
SavedState savedState

restored state

performSave

@MainThread
public final void performSave(@NonNull SavedState outBundle)

An interface for an owner of this SavedStateRegistry to perform state saving, it will call all registered providers and merge with unconsumed state.

Parameters
@NonNull SavedState outBundle

SavedState in which to place a saved state