Show which passwords are selected

This commit is contained in:
Matthew Wong
2015-08-25 13:58:55 -04:00
parent 1f612e3d8b
commit e5a72a5175

View File

@@ -82,7 +82,7 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mActionMode != null) { if (mActionMode != null) {
toggleSelection(holder.getAdapterPosition(), holder.view); toggleSelection(holder.getAdapterPosition(), holder.card, pass.getType());
if (selectedItems.isEmpty()) { if (selectedItems.isEmpty()) {
mActionMode.finish(); mActionMode.finish();
} }
@@ -98,7 +98,7 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl
if (mActionMode != null) { if (mActionMode != null) {
return false; return false;
} }
toggleSelection(holder.getAdapterPosition(), holder.view); toggleSelection(holder.getAdapterPosition(), holder.card, pass.getType());
// Start the CAB using the ActionMode.Callback // Start the CAB using the ActionMode.Callback
mActionMode = activity.startSupportActionMode(mActionModeCallback); mActionMode = activity.startSupportActionMode(mActionModeCallback);
return true; return true;
@@ -185,12 +185,18 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl
updateSelectedItems(position, selectedItems); updateSelectedItems(position, selectedItems);
} }
public void toggleSelection(int position, View view) { public void toggleSelection(int position, CardView card, char type) {
if (!selectedItems.remove(position)) { if (!selectedItems.remove(position)) {
selectedItems.add(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 { } 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));
} }
} }