davideas / FlexibleAdapter

Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Apache License 2.0
3.55k stars 548 forks source link

'SelectableAdapter.toggleSelection()' doesn't toggle selection in SINGLE mode. #763

Open tankpow opened 4 years ago

tankpow commented 4 years ago

I got a use case that clicks item once activates(selects) it and clicks it twice deactivates(deselects) it. But due to the source of 'SelectableAdapter.toggleSelection()': public void toggleSelection(int position) { if (position < 0) { return; } if (mMode == SINGLE) { clearSelection(); } boolean contains = mSelectedPositions.contains(position); if (contains) { removeSelection(position); } else { addSelection(position); } log.v("toggleSelection %s on position %s, current %s", (contains ? "removed" : "added"), position, mSelectedPositions); } If in SINGLE mode, item in 'position' can only be selected but toggled. I try to override, but many members are 'private' in 'SelectableAdapter' and 'FlexibleAdapter'.

Will toggle selection in SINGLE mode be supported in furture verson by introducing new field member something like 'toggleSelectionInSingleMode'? Thanks.

JakeWoki commented 2 years ago

adapter.toggleSelection(position) adapter.notifyItemChanged(position)