diff options
author | Matthew Wong <wongma@protonmail.ch> | 2015-08-08 11:26:07 -0400 |
---|---|---|
committer | Matthew Wong <wongma@protonmail.ch> | 2015-08-08 11:26:07 -0400 |
commit | b37b9fed5d64e896db418016d2d6090363ec81d4 (patch) | |
tree | 9000e8baf74d46811af92071b15e0583294967b4 /app | |
parent | feb8eefcc4d0825568d158199c490ff4998c9ad5 (diff) |
Ensure positions of passwords after deleted password are updated (attempt to fix #115)
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java | 9 |
1 files changed, 7 insertions, 2 deletions
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 857c8276..fb6bc8fa 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java @@ -59,8 +59,7 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl // create a new view View v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.password_row_layout, parent, false); - ViewHolder vh = new ViewHolder(v); - return vh; + return new ViewHolder(v); } // Replace the contents of a view (invoked by the layout manager) @@ -198,6 +197,12 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl if (!selectedItems.remove(position)) { selectedItems.add(position); } + for (int selected : selectedItems) { + if (selected > position) { + selectedItems.remove(selected); + selectedItems.add(selected - 1); + } + } notifyItemChanged(position); } |