lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

belongs to Maven artifact androidx.recyclerview:recyclerview-selection:1.0.0-alpha3

StorageStrategy

public abstract class StorageStrategy
extends Object

java.lang.Object
   ↳ androidx.recyclerview.selection.StorageStrategy<K>


Strategy for storing keys in saved state. Extend this class when using custom key types that aren't supported by default. Prefer use of builtin storage strategies: createStringStorage(), createLongStorage(), createParcelableStorage(Class).

See SelectionTracker.Builder for more detailed advice on which key type to use for your selection keys.

Summary

Public constructors

StorageStrategy(Class<K> type)

Creates a new instance.

Public methods

abstract Bundle asBundle(Selection<K> selection)

Creates a Bundle from supplied Selection.

abstract Selection<K> asSelection(Bundle state)

Create a Selection from supplied Bundle.

static StorageStrategy<Long> createLongStorage()
static <K extends Parcelable> StorageStrategy<K> createParcelableStorage(Class<K> type)
static StorageStrategy<String> createStringStorage()

Inherited methods

Public constructors

StorageStrategy

public StorageStrategy (Class<K> type)

Creates a new instance.

Parameters
type Class: the key type class that is being used.

Public methods

asBundle

public abstract Bundle asBundle (Selection<K> selection)

Creates a Bundle from supplied Selection.

Parameters
selection Selection: The selection to asBundle.

Returns
Bundle

asSelection

public abstract Selection<K> asSelection (Bundle state)

Create a Selection from supplied Bundle.

Parameters
state Bundle: Bundle instance that may contain parceled Selection instance.

Returns
Selection<K>

createLongStorage

public static StorageStrategy<Long> createLongStorage ()

Returns
StorageStrategy<Long> StorageStrategy suitable for use with Long keys.

createParcelableStorage

public static StorageStrategy<K> createParcelableStorage (Class<K> type)

Parameters
type Class

Returns
StorageStrategy<K> StorageStrategy suitable for use with Parcelable keys (like Uri).

createStringStorage

public static StorageStrategy<String> createStringStorage ()

Returns
StorageStrategy<String> StorageStrategy suitable for use with String keys.