From 083f340f29944bc6f026af09ddb8356325c66e4c Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 11 Aug 2015 16:59:55 -0400 Subject: Keep selectedItems up-to-date safely (behaviour was undefined before?) --- .../com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java index bcd869d8..b4ad1d81 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java @@ -190,12 +190,19 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter temp = new TreeSet<>(); for (int selected : selectedItems) { if (selected > position) { - selectedItems.remove(selected); - selectedItems.add(selected - 1); + temp.add(selected - 1); + } else { + temp.add(selected); } } + selectedItems.clear(); + selectedItems.addAll(temp); } public void toggleSelection(int position, View view) { -- cgit v1.2.3