SavedStateRegistryController


public final class SavedStateRegistryController


An API for SavedStateRegistryOwner implementations to control SavedStateRegistry.

A SavedStateRegistryOwner should call performRestore to restore the state of the SavedStateRegistry, and performSave to gather the saved state from it.

Summary

Public methods

static final @NonNull SavedStateRegistryController

Creates a SavedStateRegistryController.

final @NonNull SavedStateRegistry

The SavedStateRegistry controlled by this controller.

final void

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

final void

Restores the saved state for the owner of this SavedStateRegistry.

final void

Saves the state for the owner of this SavedStateRegistry.

Public methods

create

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

Creates a SavedStateRegistryController.

Call this during construction of the SavedStateRegistryOwner.

getSavedStateRegistry

Added in 1.0.0
public final @NonNull SavedStateRegistry getSavedStateRegistry()

The SavedStateRegistry controlled by this controller.

performAttach

Added in 1.2.0
@MainThread
public final void performAttach()

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

Call this when the owner's Lifecycle is Lifecycle.State.INITIALIZED and before calling performRestore.

performRestore

@MainThread
public final void performRestore(SavedState savedState)

Restores the saved state for the owner of this SavedStateRegistry.

Parameters
SavedState savedState

The restored state.

performSave

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

Saves the state for the owner of this SavedStateRegistry.

This calls all registered providers and merges their states with the unconsumed state.

Parameters
@NonNull SavedState outBundle

The SavedState in which to place the saved state.