Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.recyclerview:recyclerview-selection:1.0.0-rc01

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

added in version 1.0.0
public StorageStrategy (Class<K> type)

Creates a new instance.

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

Public methods

asBundle

added in version 1.0.0
public abstract Bundle asBundle (Selection<K> selection)

Creates a Bundle from supplied Selection.

Parameters
selection Selection: The selection to asBundle.

Returns
Bundle

asSelection

added in version 1.0.0
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

added in version 1.0.0
public static StorageStrategy<Long> createLongStorage ()

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

createParcelableStorage

added in version 1.0.0
public static StorageStrategy<K> createParcelableStorage (Class<K> type)

Parameters
type Class

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

createStringStorage

added in version 1.0.0
public static StorageStrategy<String> createStringStorage ()

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