diff options
author | Matthew Wong <wongma7@outlook.com> | 2015-08-25 13:58:55 -0400 |
---|---|---|
committer | Matthew Wong <wongma7@outlook.com> | 2015-08-25 13:58:55 -0400 |
commit | e5a72a5175294e955f95aa71f345cd6fa769931b (patch) | |
tree | 162754b6a044a5d69a0cb77984aa66def87b4b6b /app/src/main/java | |
parent | 1f612e3d8b9a6fbe399a3373a94e4a3ec9554908 (diff) |
Show which passwords are selected
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java | 20 |
1 files changed, 13 insertions, 7 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 208ec2eb..3671fe57 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java @@ -56,7 +56,7 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl // Create new views (invoked by the layout manager) @Override public PasswordRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, - int viewType) { + int viewType) { // create a new view View v = LayoutInflater.from(parent.getContext()) .inflate(R.layout.password_row_layout, parent, false); @@ -82,7 +82,7 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl @Override public void onClick(View v) { if (mActionMode != null) { - toggleSelection(holder.getAdapterPosition(), holder.view); + toggleSelection(holder.getAdapterPosition(), holder.card, pass.getType()); if (selectedItems.isEmpty()) { mActionMode.finish(); } @@ -98,7 +98,7 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl if (mActionMode != null) { return false; } - toggleSelection(holder.getAdapterPosition(), holder.view); + toggleSelection(holder.getAdapterPosition(), holder.card, pass.getType()); // Start the CAB using the ActionMode.Callback mActionMode = activity.startSupportActionMode(mActionModeCallback); return true; @@ -185,12 +185,18 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl updateSelectedItems(position, selectedItems); } - public void toggleSelection(int position, View view) { + public void toggleSelection(int position, CardView card, char type) { if (!selectedItems.remove(position)) { selectedItems.add(position); - view.setSelected(true); + if (type == PasswordItem.TYPE_CATEGORY) + card.setCardBackgroundColor(activity.getResources().getColor(R.color.deep_orange_200)); + else + card.setCardBackgroundColor(activity.getResources().getColor(R.color.light_blue_200)); } else { - view.setSelected(false); + if (type == PasswordItem.TYPE_CATEGORY) + card.setCardBackgroundColor(activity.getResources().getColor(R.color.deep_orange_400)); + else + card.setCardBackgroundColor(activity.getResources().getColor(R.color.light_blue_600)); } } @@ -208,4 +214,4 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl selectedItems.clear(); selectedItems.addAll(temp); } -}
\ No newline at end of file +} |