@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.action_move_to_category: moveMangasToCategories(getPresenter().selectedMangas); return true; case R.id.action_delete: getPresenter().deleteMangas(); destroyActionModeIfNeeded(); return true; } return false; }
private void toggleSelection(int position) { LibraryFragment f = getLibraryFragment(); adapter.toggleSelection(position, false); f.getPresenter().setSelection(adapter.getItem(position), adapter.isSelected(position)); int count = f.getPresenter().selectedMangas.size(); if (count == 0) { f.destroyActionModeIfNeeded(); } else { f.setContextTitle(count); f.invalidateActionMode(); } }
private void moveMangasToCategories(List<Manga> mangas) { new MaterialDialog.Builder(getActivity()) .title(R.string.action_move_category) .items(getPresenter().getCategoriesNames()) .itemsCallbackMultiChoice( null, (dialog, which, text) -> { getPresenter().moveMangasToCategories(which, mangas); destroyActionModeIfNeeded(); return true; }) .positiveText(R.string.button_ok) .negativeText(R.string.button_cancel) .show(); }