SelectionTracker.SelectionPredicate


public abstract class SelectionTracker.SelectionPredicate<K>


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

Parameters
<K>

Selection key type. @see StorageStrategy for supported types.

Summary

Public constructors

Public methods

abstract boolean

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(@NonNull K key, boolean nextState)

Validates a change to selection for a specific key.

Public constructors

SelectionPredicate

Added in 1.0.0
public SelectionPredicate()

Public methods

canSelectMultiple

Added in 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 and canSetStateAtPosition.

Returns
boolean

true if more than a single item can be selected.

canSetStateAtPosition

Added in 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
int position

the item position

boolean nextState

the next potential selected/unselected state

Returns
boolean

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

canSetStateForKey

Added in 1.0.0
public abstract boolean canSetStateForKey(@NonNull K key, boolean nextState)

Validates a change to selection for a specific key.

Parameters
@NonNull K key

the item key

boolean nextState

the next potential selected/unselected state

Returns
boolean

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