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)
annotation ItemKeyProvider.Scope

Constants

const Int

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

const 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 functions

abstract K?
getKey(position: Int)
abstract Int
getPosition(key: K)

Constants

SCOPE_CACHED

Added in 1.0.0
const val SCOPE_CACHED = 1: Int

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
const val SCOPE_MAPPED = 0: Int

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 scope: Int)

Creates a new provider with the given scope.

Parameters
@ItemKeyProvider.Scope scope: Int

Scope can't be changed at runtime.

Public functions

getKey

Added in 1.0.0
abstract fun getKey(position: Int): K?
Returns
K?

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

getPosition

Added in 1.0.0
abstract fun getPosition(key: K): Int
Returns
Int

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