MutableSelection
class MutableSelection<K : Any!> : Selection<K>
kotlin.Any | ||
↳ | androidx.recyclerview.selection.Selection<K> | |
↳ | androidx.recyclerview.selection.MutableSelection |
Subclass of Selection
exposing public support for mutating the underlying selection data. This is useful for clients of SelectionTracker
that wish to manipulate a copy of selection data obtained via SelectionTracker#copySelection(MutableSelection)
.
While the Selection
class is not intrinsically immutable, it is not mutable by non-library code. Furthermore the value returned from SelectionTracker#getSelection()
is a live view of the underlying selection, mutable by the library itself.
MutableSelection
allows clients to obtain a mutable copy of the Selection state held by the selection library. This is useful in situations where a stable snapshot of the selection is required.
Example
MutableSelection snapshot = new MutableSelection(); selectionTracker.copySelection(snapshot); // Clear the user visible selection. selectionTracker.clearSelection(); // tracker.getSelection().isEmpty() will be true. // shapshot has a copy of the previous selection.
Summary
Public constructors | |
---|---|
<init>() Subclass of |
Public methods | |
---|---|
Boolean |
add(@NonNull key: K) |
Unit |
clear() |
Unit | |
Boolean |
remove(@NonNull key: K) |
Inherited functions | |
---|---|
Public constructors
<init>
MutableSelection()
Subclass of Selection
exposing public support for mutating the underlying selection data. This is useful for clients of SelectionTracker
that wish to manipulate a copy of selection data obtained via SelectionTracker#copySelection(MutableSelection)
.
While the Selection
class is not intrinsically immutable, it is not mutable by non-library code. Furthermore the value returned from SelectionTracker#getSelection()
is a live view of the underlying selection, mutable by the library itself.
MutableSelection
allows clients to obtain a mutable copy of the Selection state held by the selection library. This is useful in situations where a stable snapshot of the selection is required.
Example
MutableSelection snapshot = new MutableSelection(); selectionTracker.copySelection(snapshot); // Clear the user visible selection. selectionTracker.clearSelection(); // tracker.getSelection().isEmpty() will be true. // shapshot has a copy of the previous selection.
See Also
Public methods
add
fun add(@NonNull key: K): Boolean
clear
fun clear(): Unit
remove
fun remove(@NonNull key: K): Boolean