From 2adbeeeba7e715ce1a26c1e56e4528cae54e8bf2 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Sun, 9 Aug 2015 13:53:31 -0400 Subject: Use getAdapterPosition instead of position variable set in onBindViewHolder --- .../pwdstore/utils/PasswordRecyclerAdapter.java | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 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 fb6bc8fa..65139074 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java @@ -1,9 +1,7 @@ package com.zeapo.pwdstore.utils; -import android.graphics.Color; import android.support.v7.view.ActionMode; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -34,7 +32,6 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter position) { selectedItems.remove(selected); selectedItems.add(selected - 1); } } - notifyItemChanged(position); + } + + public void toggleSelection(int position, View view) { + if (!selectedItems.remove(position)) { + selectedItems.add(position); + view.setSelected(true); + } else { + view.setSelected(false); + } } } \ No newline at end of file -- cgit v1.2.3