Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.recyclerview:recyclerview-selection:1.0.0-rc01

SelectionTracker.SelectionPredicate

public static abstract class SelectionTracker.SelectionPredicate
extends Object

java.lang.Object
   ↳ androidx.recyclerview.selection.SelectionTracker.SelectionPredicate<K>


Implement SelectionPredicate to control when items can be selected or unselected. See SelectionTracker.Builder.withSelectionPredicate(SelectionPredicate).

Summary

Public constructors

SelectionTracker.SelectionPredicate()

Public methods

abstract boolean canSelectMultiple()

Permits restriction to single selection mode.

abstract boolean canSetStateAtPosition(int position, boolean nextState)

Validates a change to selection for a specific position.

abstract boolean canSetStateForKey(K key, boolean nextState)

Validates a change to selection for a specific key.

Inherited methods

Public constructors

SelectionTracker.SelectionPredicate

added in version 1.0.0
public SelectionTracker.SelectionPredicate ()

Public methods

canSelectMultiple

added in version 1.0.0
public abstract boolean canSelectMultiple ()

Permits restriction to single selection mode. Single selection mode has unique behaviors in that it'll deselect an item already selected in order to select the new item.

In order to limit the number of items that can be selected, use canSetStateForKey(Object, boolean) and canSetStateAtPosition(int, boolean).

Returns
boolean true if more than a single item can be selected.

canSetStateAtPosition

added in version 1.0.0
public abstract boolean canSetStateAtPosition (int position, 
                boolean nextState)

Validates a change to selection for a specific position. If necessary use ItemKeyProvider to identy associated key.

Parameters
position int: the item position

nextState boolean: the next potential selected/unselected state

Returns
boolean true if the item at id can be set to nextState.

canSetStateForKey

added in version 1.0.0
public abstract boolean canSetStateForKey (K key, 
                boolean nextState)

Validates a change to selection for a specific key.

Parameters
key K: the item key

nextState boolean: the next potential selected/unselected state

Returns
boolean true if the item at id can be set to nextState.