Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

SelectionObserver

abstract class SelectionObserver<K : Any!>
kotlin.Any
   ↳ androidx.recyclerview.selection.SelectionTracker.SelectionObserver

Observer class providing access to information about Selection state changes.

Summary

Public constructors

Observer class providing access to information about Selection state changes.

Public methods

open Unit
onItemStateChanged(@NonNull key: K, selected: Boolean)

Called when the state of an item has been changed.

open Unit

Called immediately after completion of any set of changes, excluding those resulting in calls to onSelectionRefresh() and onSelectionRestored().

open Unit

Called when the underlying data set has changed.

open Unit

Called immediately after selection is restored.

Public constructors

<init>

SelectionObserver()

Observer class providing access to information about Selection state changes.

Public methods

onItemStateChanged

open fun onItemStateChanged(@NonNull key: K, selected: Boolean): Unit

Called when the state of an item has been changed.

onSelectionChanged

open fun onSelectionChanged(): Unit

Called immediately after completion of any set of changes, excluding those resulting in calls to onSelectionRefresh() and onSelectionRestored().

onSelectionRefresh

open fun onSelectionRefresh(): Unit

Called when the underlying data set has changed. After this method is called SelectionTracker will traverse the existing selection, calling onItemStateChanged(K, boolean) for each selected item, and deselecting any items that cannot be selected given the updated data-set (and after consulting SelectionPredicate).

onSelectionRestored

open fun onSelectionRestored(): Unit

Called immediately after selection is restored. onItemStateChanged(K, boolean) will *not* be called for individual items in the selection.