MutableSelection
class MutableSelection<K> : Selection
| kotlin.Any | ||
| ↳ | androidx.recyclerview.selection.Selection | |
| ↳ | 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 copySelection.
While the Selection class is not intrinsically immutable, it is not mutable by non-library code. Furthermore the value returned from 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.
| Parameters | |
|---|---|
<K> |
Selection key type. @see |
| See also | |
|---|---|
Selection |
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
Boolean |
add(key: K)Adds a new item to the primary selection. |
Unit |
clear()Clears the primary selection. |
Unit |
Clones primary and provisional selection from supplied |
Boolean |
remove(key: K)Removes an item from the primary selection. |
Inherited functions |
||||||
|---|---|---|---|---|---|---|
|
||||||
Public constructors
Public functions
add
fun add(key: K): Boolean
Adds a new item to the primary selection.
| Returns | |
|---|---|
Boolean |
true if the operation resulted in a modification to the selection. |
clear
fun clear(): Unit
Clears the primary selection. The provisional selection, if any, is unaffected.