Skip to content

Commit

Permalink
[Refactor] Fix multi-selection mode activation logic
Browse files Browse the repository at this point in the history
Multi-selection panel should be activated before the first selected item is
visible, and it should be deactivated after all the items are deselected.

Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Nov 18, 2024
1 parent 46b22de commit ae13ba3
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,13 @@ public final void setInSelectionMode(boolean inSelectionMode) {
public void toggleSelection(int position) {
if (isSelected(position)) {
deselect(position);
} else select(position);
notifyItemChanged(position);
notifySelectionChange();
notifyItemChanged(position);
notifySelectionChange();
} else {
select(position);
notifySelectionChange();
notifyItemChanged(position);
}
}

@UiThread
Expand All @@ -517,8 +521,8 @@ public void selectAll() {
for (int position = 0; position < getItemCount(); ++position) {
select(position);
}
notifyItemRangeChanged(0, getItemCount(), null);
notifySelectionChange();
notifyItemRangeChanged(0, getItemCount(), null);
}

@UiThread
Expand All @@ -541,8 +545,8 @@ public void selectRange(int firstPosition, int secondPosition) {
for (int position = beginPosition; position <= endPosition; ++position) {
select(position);
}
notifyItemRangeChanged(beginPosition, endPosition - beginPosition + 1);
notifySelectionChange();
notifyItemRangeChanged(beginPosition, endPosition - beginPosition + 1);
}

@Override
Expand Down

0 comments on commit ae13ba3

Please sign in to comment.