- recyclerview-selection using String as a way to identify items (this allows mutability in the list as opposed to using position of the item in the list. Position of an item might change when the list mutates)
- ActionMode is displayed when items are activated.
- Activation of an item happens when long-press and also when the delete icon is clicked (due to implementation of
inSelectionHotspot
to activate when a specific item is clicked) - Only certain items that meet the criteria get activated, others don't and those get "disabled" by making them less visible when ActionMode gets activated (
SelectionPredicate
) - If the list mutates while the user is in ActionMode the amount of selected items is updated and if there are none selected anymore then the ActionMode finishes.
- Support for multiple ViewTypes, which behave differently upon click.
Useful links:
- https://androidkt.com/recyclerview-selection-28-0-0/
- https://proandroiddev.com/a-guide-to-recyclerview-selection-3ed9f2381504
- Why
inSelectionHotspot(e)
is called ONLY if there is no items activated?
Because of this code in the library:
// Touch events select if they occur in the selection hotspot,
// otherwise they activate.
return item.inSelectionHotspot(e)
? selectItem(item)
: mOnItemActivatedListener.onItemActivated(item, e);
Using this library it makes sense to startActionMode once the first item has been activated, so the user knows that the next click will be used for activating a non-activated item or to deselect an already activated item.