/** * 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) { swipeListView.onChoiceStarted(); closeOpenedItems(); setActionsTo(SwipeListView.SWIPE_ACTION_CHOICE); } if (lastCount == 1 && count == 0) { swipeListView.onChoiceEnded(); returnOldActions(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { swipeListView.setItemChecked(position, !lastChecked); } swipeListView.onChoiceChanged(position, !lastChecked); reloadChoiceStateInView(frontView, position); }