public abstract class 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.

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

Parameters
<K>

Selection key type. Built in support is provided for String, Long, and Parcelable types. Use the respective factory method to create a StorageStrategy instance appropriate to the desired type. createStringStorage, createParcelableStorage, createLongStorage

Summary

Public constructors

Creates a new instance.

Public methods

abstract @NonNull Bundle
asBundle(@NonNull Selection<K> selection)

Creates a Bundle from supplied Selection.

abstract @Nullable Selection<K>

Create a Selection from supplied Bundle.

static @NonNull StorageStrategy<Long>
static @NonNull StorageStrategy<K>
static @NonNull StorageStrategy<String>

Public constructors

StorageStrategy

Added in 1.0.0
public StorageStrategy(@NonNull Class<K> type)

Creates a new instance.

Parameters
@NonNull Class<K> type

the key type class that is being used.

Public methods

asBundle

Added in 1.0.0
public abstract @NonNull Bundle asBundle(@NonNull Selection<K> selection)

Creates a Bundle from supplied Selection.

Parameters
@NonNull Selection<K> selection

The selection to asBundle.

asSelection

Added in 1.0.0
public abstract @Nullable Selection<K> asSelection(@NonNull Bundle state)

Create a Selection from supplied Bundle.

Parameters
@NonNull Bundle state

Bundle instance that may contain parceled Selection instance.

createLongStorage

Added in 1.0.0
public static @NonNull StorageStrategy<LongcreateLongStorage()
Returns
@NonNull StorageStrategy<Long>

StorageStrategy suitable for use with Long keys.

createParcelableStorage

Added in 1.0.0
public static @NonNull StorageStrategy<K> <K extends Parcelable> createParcelableStorage(@NonNull Class<K> type)
Returns
@NonNull StorageStrategy<K>

StorageStrategy suitable for use with Parcelable keys (like android.net.Uri).

createStringStorage

Added in 1.0.0
public static @NonNull StorageStrategy<StringcreateStringStorage()
Returns
@NonNull StorageStrategy<String>

StorageStrategy suitable for use with String keys.