You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2021. It is now read-only.
Hi, thank you for this library, it makes things much easier.
I want to leave selection mode and turn off the action mode bar if the user clicks the only remaining selected item. I've tried doing it like this
@Override
public void onClick(View v) {
if (!mMultiSelector.tapSelection(TaskListViewHolder.this)){
mPresenter.showBottomSheet(tasks.get(getAdapterPosition()), getAdapterPosition(), true);
}
if (mMultiSelector.getSelectedPositions().isEmpty()){
mMultiSelector.setSelectable(false);
}
}
But it doesn't work. The selection mode is turned off, but the action mode bar is not. What's strange is that if I call that outside the view holder, it does work. I implemented it succesfullt in onBackPressed using simply this:
public void leaveSelectMode(){
mMultiSelector.clearSelections();
mMultiSelector.setSelectable(false);
}
but it doesn't work in onClick.
Am i doing something wrong?
Thanks in advance
The text was updated successfully, but these errors were encountered:
@Adrianrff If you're using your activity as a listener for your adapter, in your SwappingViewHolder.onLongClick method you could call something like:
@OverridepublicbooleanonLongClick(Viewv) {
if (!multiSelector.isSelectable()) { // there's no item selected, start the action modelistener.onLongClick(); // in my activity (or fragment, I setup the action mode)multiSelector.setSelectable(true);
} // selection mode is activated so I just need to add selected itemsmultiSelector.setSelected(NotesViewHolder.this, true);
listener.onSelectedItem(); // in my activity/fragment, triggered every time an item is selectedreturntrue;
}
Then in my listener implementation
publicvoidonSelectedItem() {
intselectedCount = mAdapter.multiSelector.getSelectedPositions().size();
if (selectedCount > 0) {
// do stuff, there are Items selected (at least one)
} else {
// there's no items selected, so leave the action modeif (mActionmode != null) {
mActionmode.finish();
}
}
}
Note: mActionmode is set in the ModalMultiSelectorCallback.onCreateActionMode
Thank you. I figured it out a few moments ago. The problem was that I wasn't manually finishing the action mode. What confuses me though is why it works outside the view holder by calling setSelectable(false) without manually finishing action mode.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, thank you for this library, it makes things much easier.
I want to leave selection mode and turn off the action mode bar if the user clicks the only remaining selected item. I've tried doing it like this
But it doesn't work. The selection mode is turned off, but the action mode bar is not. What's strange is that if I call that outside the view holder, it does work. I implemented it succesfullt in onBackPressed using simply this:
but it doesn't work in onClick.
Am i doing something wrong?
Thanks in advance
The text was updated successfully, but these errors were encountered: