ItemKeyProvider
public abstract class ItemKeyProvider<K>
StableIdKeyProvider |
An |
Provides selection library access to stable selection keys identifying items presented by a RecyclerView instance.
| Parameters | |
|---|---|
<K> |
Selection key type. @see |
Summary
Nested types |
|---|
@IntDef(value = ) |
Constants |
|
|---|---|
static final int |
SCOPE_CACHED = 1Provides access to cached data based for items that were recently bound in the view. |
static final int |
SCOPE_MAPPED = 0Provides access to all data, regardless of whether it is bound to a view or not. |
Protected constructors |
|---|
ItemKeyProvider(@ItemKeyProvider.Scope int scope)Creates a new provider with the given scope. |
Public methods |
|
|---|---|
abstract @Nullable K |
getKey(int position) |
abstract int |
getPosition(@NonNull K key) |
Constants
SCOPE_CACHED
public static final int SCOPE_CACHED = 1
Provides access to cached data based for items that were recently bound in the view. Employing this provider will result in a reduced feature-set, as some features like SHIFT+click range selection and band selection are dependent on mapped access.
SCOPE_MAPPED
public static final int SCOPE_MAPPED = 0
Provides access to all data, regardless of whether it is bound to a view or not. Key providers with this access type enjoy support for enhanced features like: SHIFT+click range selection, and band selection.
Protected constructors
ItemKeyProvider
protected ItemKeyProvider(@ItemKeyProvider.Scope int scope)
Creates a new provider with the given scope.
| Parameters | |
|---|---|
@ItemKeyProvider.Scope int scope |
Scope can't be changed at runtime. |
Public methods
getKey
public abstract @Nullable K getKey(int position)
| Returns | |
|---|---|
@Nullable K |
The selection key at the given adapter position, or null. |
getPosition
public abstract int getPosition(@NonNull K key)
| Returns | |
|---|---|
int |
the position corresponding to the selection key, or RecyclerView.NO_POSITION. |