SelectionTracker.SelectionPredicate


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 functions

abstract Boolean

Permits restriction to single selection mode.

abstract Boolean
canSetStateAtPosition(position: Int, nextState: Boolean)

Validates a change to selection for a specific position.

abstract Boolean
canSetStateForKey(key: K, nextState: Boolean)

Validates a change to selection for a specific key.

Public constructors

SelectionPredicate

Added in 1.0.0
SelectionPredicate()

Public functions

canSelectMultiple

Added in 1.0.0
abstract fun canSelectMultiple(): Boolean

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
abstract fun canSetStateAtPosition(position: Int, nextState: Boolean): Boolean

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 1.0.0
abstract fun canSetStateForKey(key: K, nextState: Boolean): Boolean

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.