public abstract class ItemKeyProvider<K>

Known direct subclasses
StableIdKeyProvider

An ItemKeyProvider that provides stable ids by way of cached RecyclerView.Adapter stable ids.


Provides selection library access to stable selection keys identifying items presented by a RecyclerView instance.

Parameters
<K>

Selection key type. @see StorageStrategy for supported types.

Summary

Nested types

@IntDef(value = )
@Retention(value = RetentionPolicy.SOURCE)
public annotation ItemKeyProvider.Scope

Constants

static final int

Provides access to cached data based for items that were recently bound in the view.

static final int

Provides access to all data, regardless of whether it is bound to a view or not.

Protected constructors

Creates a new provider with the given scope.

Public methods

abstract @Nullable K
getKey(int position)
abstract int

Constants

SCOPE_CACHED

Added in 1.0.0
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

Added in 1.0.0
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

Added in 1.0.0
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

Added in 1.0.0
public abstract @NullablegetKey(int position)
Returns
@Nullable K

The selection key at the given adapter position, or null.

getPosition

Added in 1.0.0
public abstract int getPosition(@NonNull K key)
Returns
int

the position corresponding to the selection key, or RecyclerView.NO_POSITION.