List of usage examples for android.view ActionMode finish
public abstract void finish();
From source file:net.named_data.nfd.FaceListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @SuppressLint("InflateParams") View v = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_face_list_list_header, null); getListView().addHeaderView(v, null, false); getListView().setDivider(getResources().getDrawable(R.drawable.list_item_divider)); // Get info unavailable view m_faceListInfoUnavailableView = v.findViewById(R.id.face_list_info_unavailable); // Get progress bar spinner view m_reloadingListProgressBar = (ProgressBar) v.findViewById(R.id.face_list_reloading_list_progress_bar); // Setup list view for deletion ListView listView = getListView(); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override/* w ww . j a v a 2 s. c o m*/ public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { if (checked && id < 256) { getListView().setItemChecked(position, false); return; } if (checked) m_facesToDelete.add((int) id); else m_facesToDelete.remove((int) id); } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater menuInflater = mode.getMenuInflater(); menuInflater.inflate(R.menu.menu_face_list_multiple_modal_menu, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_delete_face_item: G.Log("Requesting to delete " + String.valueOf(m_facesToDelete)); // Delete selected faceIds m_faceDestroyAsyncTask = new FaceDestroyAsyncTask(); m_faceDestroyAsyncTask.execute(m_facesToDelete); m_facesToDelete = new HashSet<>(); mode.finish(); return true; default: return false; } } @Override public void onDestroyActionMode(ActionMode mode) { } private HashSet<Integer> m_facesToDelete = new HashSet<>(); }); }
From source file:de.azapps.mirakel.main_activity.tasks_fragment.TasksFragment.java
@SuppressLint("NewApi") protected void update(final boolean reset) { if (!this.created) { return;//from w ww . j a va2 s . c om } this.listView = (ListView) this.view.findViewById(R.id.tasks_list); this.adapter = new TaskAdapter(getActivity(), new OnTaskChangedListner() { @Override public void onTaskChanged(final Task newTask) { getLoaderManager().restartLoader(0, null, TasksFragment.this); if (MirakelCommonPreferences.isTablet() && TasksFragment.this.main.getTaskFragment() != null && TasksFragment.this.main.getTaskFragment().getTask().getId() == newTask.getId()) { TasksFragment.this.main.getTaskFragment().update(newTask); } } }); adapter.setFilterQueryProvider(this); this.listView.setAdapter(this.adapter); getLoaderManager().initLoader(0, null, this); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { this.listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> parent, final View item, final int position, final long id) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final Task task = Task.get((Long) item.getTag()).orNull(); if (task == null) { return false; } builder.setTitle(task.getName()); final List<CharSequence> items = new ArrayList<CharSequence>( Arrays.asList(getActivity().getResources().getStringArray(R.array.task_actions_items))); builder.setItems(items.toArray(new CharSequence[items.size()]), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int item) { switch (item) { case TASK_RENAME: TasksFragment.this.main.setCurrentTask(task); break; case TASK_MOVE: TasksFragment.this.main.handleMoveTask(task); break; case TASK_DESTROY: TasksFragment.this.main.handleDestroyTask(task); break; default: break; } } }); final AlertDialog dialog = builder.create(); dialog.show(); return true; } }); } else { this.listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); this.listView.setHapticFeedbackEnabled(true); this.listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.menu_delete: TasksFragment.this.main.handleDestroyTask(TasksFragment.this.selectedTasks); break; case R.id.menu_move: TasksFragment.this.main.handleMoveTask(TasksFragment.this.selectedTasks); break; case R.id.menu_set_due: TasksFragment.this.main.handleSetDue(TasksFragment.this.selectedTasks); break; case R.id.edit_task: TasksFragment.this.main.setCurrentTask(TasksFragment.this.selectedTasks.get(0), true); break; case R.id.done_task: for (final Task t : TasksFragment.this.selectedTasks) { t.setDone(true); t.save(); } getLoaderManager().restartLoader(0, null, TasksFragment.this); break; default: break; } mode.finish(); return false; } @Override public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.context_tasks, menu); TasksFragment.this.mActionMode = mode; clearFocus(); TasksFragment.this.selectedTasks = new ArrayList<>(); return true; } @Override public void onDestroyActionMode(final ActionMode mode) { TasksFragment.this.selectedTasks = new ArrayList<>(); } @Override public void onItemCheckedStateChanged(final ActionMode mode, final int position, final long id, final boolean checked) { final Cursor cursor = (Cursor) TasksFragment.this.listView.getItemAtPosition(position); if (cursor.getCount() > 0) { final Task t = new Task(cursor); if (!TasksFragment.this.selectedTasks.contains(t) && checked) { TasksFragment.this.selectedTasks.add(t); } else if (checked) { TasksFragment.this.selectedTasks.remove(t); } } } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { menu.findItem(R.id.edit_task).setVisible(TasksFragment.this.selectedTasks.size() <= 1); return false; } }); } this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View item, final int position, final long id) { long taskId = (Long) item.getTag(); Optional<Task> taskOptional = Task.get(taskId); if (taskOptional.isPresent()) { TasksFragment.this.main.setCurrentTask(taskOptional.get(), true); } else { throw new TaskVanishedException(taskId); } } }); }
From source file:me.acristoffers.tracker.activities.PackageListActivity.java
@Override public boolean onActionItemClicked(final ActionMode actionMode, final MenuItem menuItem) { boolean result = false; switch (menuItem.getItemId()) { case R.id.remove: final String body = getString(R.string.confirm_delete, longClickPackage.getName()); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.are_you_sure); builder.setMessage(body);/*from w w w . j a v a 2 s. c om*/ builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { for (final Object o : selection) { final Package pkg = (Package) o; pkg.remove(); } packageListFragment.reloadData(); if (isTablet) { final FragmentManager supportFragmentManager = getSupportFragmentManager(); final FragmentTransaction transaction = supportFragmentManager.beginTransaction(); transaction.replace(R.id.package_details, new BlankFragment()); transaction.commit(); } dialogInterface.dismiss(); actionMode.finish(); } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); final AlertDialog dialog = builder.create(); dialog.show(); return true; case R.id.set_active: for (final Package pkg : selection) { pkg.setActive(true); pkg.save(); } packageListFragment.reloadData(); result = true; break; case R.id.set_inactive: for (final Package pkg : selection) { pkg.setActive(false); pkg.save(); } packageListFragment.reloadData(); result = true; break; case R.id.edit: if (isTablet) { final Bundle args = new Bundle(); args.putString(PackageDetailsActivity.PACKAGE_CODE, selection.get(0).getCod()); final PackageEditFragment fragment = new PackageEditFragment(); fragment.setArguments(args); final FragmentManager supportFragmentManager = getSupportFragmentManager(); if (supportFragmentManager != null) { final FragmentTransaction transaction = supportFragmentManager.beginTransaction(); transaction.replace(R.id.package_details, fragment); transaction.commit(); } } else { final Intent intent = new Intent(this, PackageEditActivity.class); intent.putExtra(PackageDetailsActivity.PACKAGE_CODE, selection.get(0).getCod()); startActivity(intent); } result = true; break; } actionMode.finish(); return result; }
From source file:org.jraf.android.bikey.app.ride.list.RideListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setEmptyText(getString(R.string.ride_list_empty)); ListView listView = getListView(); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override//from w w w . java2 s . c o m public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.setTitle(R.string.ride_list_title); int quantity = getListView().getCheckedItemCount(); mode.setSubtitle( getResources().getQuantityString(R.plurals.ride_list_cab_subtitle, quantity, quantity)); MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.ride_list_contextual, menu); return true; } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { int quantity = getListView().getCheckedItemCount(); mode.setSubtitle( getResources().getQuantityString(R.plurals.ride_list_cab_subtitle, quantity, quantity)); // Enable share / edit if only one item is selected (can't share / edit several items at the same time) mode.getMenu().findItem(R.id.action_share).setVisible(quantity == 1); mode.getMenu().findItem(R.id.action_edit).setVisible(quantity == 1); // Enable merge only if several items are selected mode.getMenu().findItem(R.id.action_merge).setVisible(quantity > 1); } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { long[] checkedItemIds = getListView().getCheckedItemIds(); long checkedItemId = checkedItemIds[0]; Uri checkedItemUri = ContentUris.withAppendedId(RideColumns.CONTENT_URI, checkedItemId); switch (item.getItemId()) { case R.id.action_delete: getCallbacks().showDeleteDialog(checkedItemIds); mode.finish(); return true; case R.id.action_share: getCallbacks().showShareDialog(checkedItemUri); mode.finish(); return true; case R.id.action_edit: getCallbacks().edit(checkedItemUri); mode.finish(); return true; case R.id.action_merge: getCallbacks().showMergeDialog(checkedItemIds); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } }); }
From source file:com.mishiranu.dashchan.ui.navigator.page.PostsPage.java
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case ACTION_MENU_MAKE_THREADSHOT: { ArrayList<PostItem> postItems = getAdapter().getSelectedItems(); if (postItems.size() > 0) { PageHolder pageHolder = getPageHolder(); String threadTitle = getAdapter().getConfigurationSet().gallerySet.getThreadTitle(); new ThreadshotPerformer(getListView(), getUiManager(), pageHolder.chanName, pageHolder.boardName, pageHolder.threadNumber, threadTitle, postItems); }/*from w w w . j av a 2s . c o m*/ mode.finish(); return true; } case ACTION_MENU_REPLY: { ArrayList<Replyable.ReplyData> data = new ArrayList<>(); for (PostItem postItem : getAdapter().getSelectedItems()) { data.add(new Replyable.ReplyData(postItem.getPostNumber(), null)); } if (data.size() > 0) { replyable.onRequestReply(CommonUtils.toArray(data, Replyable.ReplyData.class)); } mode.finish(); return true; } case ACTION_MENU_DELETE_POSTS: { ArrayList<PostItem> postItems = getAdapter().getSelectedItems(); ArrayList<String> postNumbers = new ArrayList<>(); for (PostItem postItem : postItems) { if (!postItem.isDeleted()) { postNumbers.add(postItem.getPostNumber()); } } if (postNumbers.size() > 0) { PageHolder pageHolder = getPageHolder(); getUiManager().dialog().performSendDeletePosts(pageHolder.chanName, pageHolder.boardName, pageHolder.threadNumber, postNumbers); } mode.finish(); return true; } case ACTION_MENU_SEND_REPORT: { ArrayList<PostItem> postItems = getAdapter().getSelectedItems(); ArrayList<String> postNumbers = new ArrayList<>(); for (PostItem postItem : postItems) { if (!postItem.isDeleted()) { postNumbers.add(postItem.getPostNumber()); } } if (postNumbers.size() > 0) { PageHolder pageHolder = getPageHolder(); getUiManager().dialog().performSendReportPosts(pageHolder.chanName, pageHolder.boardName, pageHolder.threadNumber, postNumbers); } mode.finish(); return true; } } return false; }
From source file:cat.wuyingren.rorhelper.fragments.GameListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); dataSource = new GameDataSource(getActivity()); dataSource.open();/* w ww. ja v a 2 s.co m*/ values = dataSource.getAllGames(); adapter = new MultipleRowAdapter(getActivity(), values); setListAdapter(adapter); final ListView listView = getListView(); listView.setItemsCanFocus(false); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new ListView.MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are selected/de-selected, // such as update the title in the CAB //mode.setTag(); int selectionColor = getResources().getColor(R.color.colorPrimary); Log.w("TAG", "onItemCheckedStateChanged() " + checked + " " + position); mode.setSubtitle(listView.getCheckedItemCount() + " selected"); if (checked) { listView.getChildAt(position).setBackgroundColor(selectionColor); } else { listView.getChildAt(position) .setBackgroundColor(getResources().getColor(android.R.color.transparent)); } } @Override public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) { // Inflate the menu for the CAB Log.w("TAG", "onCreateActionMode"); MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.menu_context, menu); mode.setTitle(getString(R.string.action_choose)); return true; } @Override public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) { // Here you can perform updates to the CAB due to // an invalidate() request return false; } @Override public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB switch (item.getItemId()) { case R.id.action_delete: deleteItems(listView.getCheckedItemPositions()); mode.finish(); return true; default: return false; } } @Override public void onDestroyActionMode(android.view.ActionMode mode) { // Here you can make any necessary updates to the activity when // the CAB is removed. By default, selected items are deselected/unchecked. SparseBooleanArray checked = listView.getCheckedItemPositions(); for (int i = 0; i < listView.getAdapter().getCount(); i++) { if (checked.get(i)) { listView.getChildAt(i) .setBackgroundColor(getResources().getColor(android.R.color.transparent)); } } } }); // dataSource.close(); }
From source file:com.miz.mizuu.fragments.TvShowLibraryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.image_grid_fragment, container, false); mProgressBar = (ProgressBar) v.findViewById(R.id.progress); mEmptyLibraryLayout = v.findViewById(R.id.empty_library_layout); mEmptyLibraryTitle = (TextView) v.findViewById(R.id.empty_library_title); mEmptyLibraryTitle.setTypeface(TypefaceUtils.getRobotoCondensedRegular(mContext)); mEmptyLibraryDescription = (TextView) v.findViewById(R.id.empty_library_description); mEmptyLibraryDescription.setTypeface(TypefaceUtils.getRobotoLight(mContext)); mAdapter = new LoaderAdapter(mContext); mGridView = (ObservableGridView) v.findViewById(R.id.gridView); mGridView.setAdapter(mAdapter);//from w w w. ja va 2 s . co m mGridView.setColumnWidth(mImageThumbSize); mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { viewTvShowDetails(arg2, arg1); } }); mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL); mGridView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { mAdapter.setItemChecked(position, checked); mode.setTitle(String.format(getString(R.string.selected), mAdapter.getCheckedItemCount())); } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { getActivity().getMenuInflater().inflate(R.menu.show_library_cab, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.show_add_fav: TvShowDatabaseUtils.setTvShowsFavourite(mContext, mAdapter.getCheckedShows(), true); break; case R.id.show_remove_fav: TvShowDatabaseUtils.setTvShowsFavourite(mContext, mAdapter.getCheckedShows(), false); break; case R.id.show_watched: TvShowDatabaseUtils.setTvShowsWatched(mContext, mAdapter.getCheckedShows(), true); break; case R.id.show_unwatched: TvShowDatabaseUtils.setTvShowsWatched(mContext, mAdapter.getCheckedShows(), false); break; } if (!(id == R.id.watched_menu || id == R.id.favorite_menu)) { mode.finish(); LocalBroadcastUtils.updateTvShowLibrary(mContext); } return true; } @Override public void onDestroyActionMode(ActionMode mode) { mAdapter.clearCheckedItems(); } }); mTvShowLoader = new TvShowLoader(mContext, TvShowLibraryType.fromInt(getArguments().getInt("type")), mCallback); mTvShowLoader.load(); showProgressBar(); return v; }
From source file:com.btmura.android.reddit.app.NavigationFragment.java
@Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { int count = getListView().getCheckedItemCount(); boolean aboutItemVisible = count == 1; boolean shareItemsVisible = count == 1; boolean deleteItemVisible = true; SparseBooleanArray checked = getListView().getCheckedItemPositions(); int size = checked.size(); for (int i = 0; i < size; i++) { if (checked.valueAt(i)) { int position = checked.keyAt(i); int adapterIndex = mergeAdapter.getAdapterIndex(position); switch (adapterIndex) { case ADAPTER_ACCOUNTS: case ADAPTER_PLACES: aboutItemVisible = shareItemsVisible = deleteItemVisible = false; break; case ADAPTER_SUBREDDITS: int adapterPosition = mergeAdapter.getAdapterPosition(position); String subreddit = subredditAdapter.getName(adapterPosition); boolean hasSidebar = Subreddits.hasSidebar(subreddit); aboutItemVisible &= hasSidebar; shareItemsVisible &= hasSidebar; deleteItemVisible &= hasSidebar; break; }/*w w w . ja v a2 s . c om*/ } } if (aboutItemVisible || shareItemsVisible || deleteItemVisible) { prepareMode(mode, count); prepareAddItem(menu); prepareAboutItem(menu, aboutItemVisible); prepareDeleteItem(menu, deleteItemVisible); prepareShareItems(menu, shareItemsVisible); } else { mode.finish(); } return true; }
From source file:com.makotojava.android.debate.PolicySpeechFragment.java
private void createCrossExTimerOnLongClickListener(TextView speechTimer) { speechTimer.setOnLongClickListener(new OnLongClickListener() { @Override//from w ww.j av a2s. c om public boolean onLongClick(View v) { getActivity().startActionMode(new ActionMode.Callback() { @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public void onDestroyActionMode(ActionMode mode) { // Nothing to do } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.crossex_timer_context_menu, menu); return true; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { boolean ret = false; switch (item.getItemId()) { case R.id.crossex_context_menu_reset: Log.i(TAG, "CONTEXT MENU: CrossEx Timer **RESET**"); long originalDurationInMillis = _crossexTimer.reset(); updateTimerTextView(_crossexTimerTextView, originalDurationInMillis); _crossexTimerTextView.setTextColor(Color.BLACK); mode.finish(); ret = true; break; case R.id.crossex_context_menu_set: Log.i(TAG, "CONTEXT MENU: CrossEx Timer **SET**"); // Display dialog to set Timer FragmentManager fragMan = getActivity().getFragmentManager(); TimePickerFragment dialog = TimePickerFragment.newInstance( _crossexTimer.getMillisUntilFinished(), _speech.getCrossExDurationInMinutes(), RQID_CROSSEXTIMER); dialog.setTargetFragment(PolicySpeechFragment.this, 0); dialog.show(fragMan, MINUTES_SECONDS_PICKER_TITLE); _crossexTimerTextView.setTextColor(Color.BLACK); mode.finish(); ret = true; break; } return ret; } }); return true; } }); }
From source file:com.github.jvanhie.discogsscrobbler.ReleaseListFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setSelection() { mList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); mList.setSelector(R.drawable.track_selector); mList.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override// w ww. j a v a 2 s. co m public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.list_cab, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { SparseBooleanArray checkedItems = mList.getCheckedItemPositions(); final List<Release> releases = new ArrayList<Release>(); if (checkedItems != null) { for (int i = 0; i < checkedItems.size(); i++) { if (checkedItems.valueAt(i)) { releases.add((Release) mList.getAdapter().getItem(checkedItems.keyAt(i))); } } } switch (item.getItemId()) { case R.id.reload_release: mCallbacks.setRefreshVisible(true); mDiscogs.refreshReleases(releases, new Discogs.DiscogsWaiter() { @Override public void onResult(boolean success) { if (success) { Toast.makeText(getActivity(), "reloaded releases", Toast.LENGTH_SHORT).show(); loadList(); } else { Toast.makeText(getActivity(), "Failed to reload requested releases!", Toast.LENGTH_SHORT).show(); } mCallbacks.setRefreshVisible(false); } }); mode.finish(); break; case R.id.delete_release: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Add the buttons builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button mCallbacks.setRefreshVisible(true); mDiscogs.removeReleases(releases, new Discogs.DiscogsWaiter() { @Override public void onResult(boolean success) { if (success) { Toast.makeText(getActivity(), "Removed selected releases", Toast.LENGTH_SHORT).show(); loadList(); } else { Toast.makeText(getActivity(), "Failed to remove selected releases!", Toast.LENGTH_SHORT).show(); } mCallbacks.setRefreshVisible(false); } }); mode.finish(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mode.finish(); } }); builder.setTitle(R.string.delete_releases_title).setMessage(R.string.delete_releases_message); AlertDialog dialog = builder.create(); dialog.show(); break; case R.id.cancel_selection: mode.finish(); } return false; } @Override public void onDestroyActionMode(ActionMode actionMode) { } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { mode.setTitle(mList.getCheckedItemCount() + " releases selected"); } }); }