mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 22:35:17 +00:00
Keep selectedItems up-to-date safely (behaviour was undefined before?)
This commit is contained in:
@@ -190,12 +190,19 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl
|
|||||||
public void remove(int position) {
|
public void remove(int position) {
|
||||||
this.values.remove(position);
|
this.values.remove(position);
|
||||||
this.notifyItemRemoved(position);
|
this.notifyItemRemoved(position);
|
||||||
|
|
||||||
|
// keep selectedItems updated so we know what to notifyItemChanged
|
||||||
|
// (instead of just using notifyDataSetChanged)
|
||||||
|
Set<Integer> temp = new TreeSet<>();
|
||||||
for (int selected : selectedItems) {
|
for (int selected : selectedItems) {
|
||||||
if (selected > position) {
|
if (selected > position) {
|
||||||
selectedItems.remove(selected);
|
temp.add(selected - 1);
|
||||||
selectedItems.add(selected - 1);
|
} else {
|
||||||
|
temp.add(selected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
selectedItems.clear();
|
||||||
|
selectedItems.addAll(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleSelection(int position, View view) {
|
public void toggleSelection(int position, View view) {
|
||||||
|
Reference in New Issue
Block a user