StorageStrategy
abstract class StorageStrategy<K : Any!>
kotlin.Any | |
↳ | androidx.recyclerview.selection.StorageStrategy |
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 | |
---|---|
Creates a new instance. |
Public methods | |
---|---|
abstract Bundle | |
abstract Selection<K>? |
asSelection(@NonNull state: Bundle) |
open static StorageStrategy<Long!> | |
open static StorageStrategy<K> |
createParcelableStorage(@NonNull type: Class<K>) |
open static StorageStrategy<String!> |
Public constructors
<init>
StorageStrategy(@NonNull type: Class<K>)
Creates a new instance.
Parameters | |
---|---|
type |
Class<K>: the key type class that is being used. |
Public methods
asBundle
@NonNull abstract fun asBundle(@NonNull selection: Selection<K>): Bundle
Creates a Bundle
from supplied Selection
.
Parameters | |
---|---|
selection |
Selection<K>: The selection to asBundle. |
asSelection
@Nullable abstract fun asSelection(@NonNull state: Bundle): Selection<K>?
Create a Selection
from supplied Bundle
.
Parameters | |
---|---|
state |
Bundle: Bundle instance that may contain parceled Selection instance. |
createLongStorage
@NonNull open static fun createLongStorage(): StorageStrategy<Long!>
Return | |
---|---|
StorageStrategy<Long!> |
StorageStrategy suitable for use with Long keys. |
createParcelableStorage
@NonNull open static fun <K : Parcelable!> createParcelableStorage(@NonNull type: Class<K>): StorageStrategy<K>
Return | |
---|---|
StorageStrategy<K> |
StorageStrategy suitable for use with Parcelable keys (like android.net.Uri ). |
createStringStorage
@NonNull open static fun createStringStorage(): StorageStrategy<String!>
Return | |
---|---|
StorageStrategy<String!> |
StorageStrategy suitable for use with String keys. |