LimitedSelectableTask
A task that limits the number of selectable items.
This task operates on a list of ViewData and ensures that the number of selected items does not exceed a specified limit. It achieves this by:
Filtering AppInfoViewData instances that have a androidx.picker.loader.select.SelectableItem.
Tracking the currently selected AppInfo instances in a HashSet.
Registering listeners on each androidx.picker.loader.select.SelectableItem:
A
beforeChangeUpdateListener
to prevent selection if the limit is reached.An
afterChangeUpdateListener
to update theselectedSet
and the dimmed state of other items.Dimming items that are not selected when the selection limit is reached.
The task also manages DisposableHandle instances for the registered listeners, ensuring they are disposed of when the task is re-executed or no longer needed.
Parameters
The maximum number of items that can be selected.