/** Unselected choice state in item */ protected void unselectedChoiceStates() { int start = mLayoutManager.findFirstVisibleItemPosition(); int end = mLayoutManager.findLastVisibleItemPosition(); for (int i = 0; i < checked.size(); i++) { if (checked.get(i) && i >= start && i <= end) { reloadChoiceStateInView( swipeRecyclerView.getChildAt(i - start).findViewById(swipeFrontView), i); } checked.set(i, false); } swipeRecyclerView.onChoiceEnded(); returnOldActions(); }
/** * Swap choice state in item * * @param position position of list */ private void swapChoiceState(int position) { int lastCount = getCountSelected(); boolean lastChecked = checked.get(position); checked.set(position, !lastChecked); int count = lastChecked ? lastCount - 1 : lastCount + 1; if (lastCount == 0 && count == 1) { swipeRecyclerView.onChoiceStarted(); closeOpenedItems(); setActionsTo(SwipeRecyclerView.SWIPE_ACTION_CHOICE); } if (lastCount == 1 && count == 0) { swipeRecyclerView.onChoiceEnded(); returnOldActions(); } // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // swipeListView.setItemChecked(position, !lastChecked); // } swipeRecyclerView.onChoiceChanged(position, !lastChecked); reloadChoiceStateInView(frontView, position); }