Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tankpow opened this issue Jun 11, 2020 · 1 comment

Comments

@tankpow
Copy link

tankpow commented Jun 11, 2020

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants