public abstract class

SelectionTracker.SelectionPredicate<K>

extends java.lang.Object

 java.lang.Object

↳androidx.recyclerview.selection.SelectionTracker.SelectionPredicate<K>

Overview

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

Summary

Constructors
publicSelectionPredicate()

Methods
public abstract booleancanSelectMultiple()

Permits restriction to single selection mode.

public abstract booleancanSetStateAtPosition(int position, boolean nextState)

Validates a change to selection for a specific position.

public abstract booleancanSetStateForKey(java.lang.Object key, boolean nextState)

Validates a change to selection for a specific key.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public SelectionPredicate()

Methods

public abstract boolean canSetStateForKey(java.lang.Object key, boolean nextState)

Validates a change to selection for a specific key.

Parameters:

key: the item key
nextState: the next potential selected/unselected state

Returns:

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

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: the item position
nextState: the next potential selected/unselected state

Returns:

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

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 SelectionTracker.SelectionPredicate.canSetStateForKey(K, boolean) and SelectionTracker.SelectionPredicate.canSetStateAtPosition(int, boolean).

Returns:

true if more than a single item can be selected.