StorageStrategy
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. |
Summary
Public constructors |
|---|
StorageStrategy(type: Class<K!>)Creates a new instance. |
Public functions |
|
|---|---|
abstract Bundle |
|
abstract Selection<K!>? |
asSelection(state: Bundle) |
java-static StorageStrategy<Long!> |
|
java-static StorageStrategy<K!> |
<K : Parcelable?> createParcelableStorage(type: Class<K!>) |
java-static StorageStrategy<String!> |
Public constructors
StorageStrategy
StorageStrategy(type: Class<K!>)
Creates a new instance.
| Parameters | |
|---|---|
type: Class<K!> |
the key type class that is being used. |
Public functions
asBundle
abstract fun asBundle(selection: Selection<K!>): Bundle
Creates a Bundle from supplied Selection.
| Parameters | |
|---|---|
selection: Selection<K!> |
The selection to asBundle. |
asSelection
abstract fun asSelection(state: Bundle): Selection<K!>?
Create a Selection from supplied Bundle.
| Parameters | |
|---|---|
state: Bundle |
Bundle instance that may contain parceled Selection instance. |
createLongStorage
java-static fun createLongStorage(): StorageStrategy<Long!>
| Returns | |
|---|---|
StorageStrategy<Long!> |
StorageStrategy suitable for use with |
createParcelableStorage
java-static fun <K : Parcelable?> createParcelableStorage(type: Class<K!>): StorageStrategy<K!>
| Returns | |
|---|---|
StorageStrategy<K!> |
StorageStrategy suitable for use with |
createStringStorage
java-static fun createStringStorage(): StorageStrategy<String!>
| Returns | |
|---|---|
StorageStrategy<String!> |
StorageStrategy suitable for use with |