lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

belongs to Maven artifact androidx.recyclerview:recyclerview-selection:1.0.0-alpha3

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

public SelectionTracker.SelectionPredicate ()

Public methods

canSelectMultiple

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

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

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.