Java Code Examples for androidx.appcompat.view.ActionMode#finish()
The following examples show how to use
androidx.appcompat.view.ActionMode#finish() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QiscusBaseChatActivity.java From qiscus-sdk-android with Apache License 2.0 | 6 votes |
protected void onSelectedCommentsAction(ActionMode mode, MenuItem item, List<QiscusComment> selectedComments) { int i = item.getItemId(); if (i == R.id.action_copy) { copyComments(selectedComments); } else if (i == R.id.action_share) { if (selectedComments.size() > 0) { shareComment(selectedComments.get(0)); } } else if (i == R.id.action_reply) { if (selectedComments.size() > 0) { replyComment(selectedComments.get(0)); } } else if (i == R.id.action_forward) { forwardComments(selectedComments); } else if (i == R.id.action_info && selectedComments.size() > 0) { showCommentInfo(selectedComments.get(0)); } else if (i == R.id.action_delete && selectedComments.size() > 0) { deleteComments(selectedComments); } mode.finish(); }
Example 2
Source File: FavoriteRecyclerViewAdapter.java From materialistic with Apache License 2.0 | 6 votes |
@Override public boolean onActionItemClicked(final ActionMode actionMode, MenuItem menuItem) { if (menuItem.getItemId() == R.id.menu_clear) { mAlertDialogBuilder .init(mContext) .setMessage(R.string.confirm_clear_selected) .setPositiveButton(android.R.string.ok, (dialog, which) -> { mPendingClear = true; removeSelection(); actionMode.finish(); }) .setNegativeButton(android.R.string.cancel, null) .create() .show(); return true; } if (menuItem.getItemId() == R.id.menu_refresh) { refreshSelection(); actionMode.finish(); } return false; }
Example 3
Source File: CGroupActivity.java From call_manage with MIT License | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.action_dismiss: mAdapter.enableEditMode(false); mode.finish(); // Action picked, so close the CAB return true; default: return false; } }
Example 4
Source File: ChatMessagesFragment.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.action_copy: copySelectedMessages(); mode.finish(); return true; case R.id.action_share: shareSelectedMessages(); mode.finish(); return true; case R.id.action_delete: { int cnt = mAdapter.getSelectedItems().size(); new AlertDialog.Builder(getContext()) .setTitle(R.string.action_delete_confirm_title) .setMessage(getResources().getQuantityString(R.plurals.message_delete_confirm, cnt, cnt) + "\n\n" + getResources().getString(R.string.message_delete_confirm_note)) .setPositiveButton(R.string.action_delete, (di, w) -> { deleteSelectedMessages(); mode.finish(); }) .setNegativeButton(R.string.action_cancel, null) .show(); return true; } default: return false; } }
Example 5
Source File: QiscusBaseChatActivity.java From qiscus-sdk-android with Apache License 2.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { QiscusBaseChatFragment fragment = getChatFragment(); if (fragment == null) { mode.finish(); return false; } onSelectedCommentsAction(mode, item, fragment.getSelectedComments()); return false; }
Example 6
Source File: ProfileDocumentsFragment.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.delete: handleDeleteMedia(getListAdapter().getSelectedMedia()); mode.finish(); return true; } return false; }
Example 7
Source File: ProfileGalleryFragment.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.delete: handleDeleteMedia(getListAdapter().getSelectedMedia()); mode.finish(); return true; } return false; }
Example 8
Source File: MessageActivity.java From toktok-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem item) { final int id = item.getItemId(); if (id == R.id.action_message_delete) { mRecyclerAdapter.deleteSelected(); mode.finish(); } return true; }
Example 9
Source File: ActionModeHelper.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@CallSuper @Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem item) { boolean consumed = false; if (mCallback != null) { consumed = mCallback.onActionItemClicked(actionMode, item); } if (!consumed) { // Finish the actionMode actionMode.finish(); } return consumed; }
Example 10
Source File: CourseOutlineFragment.java From edx-app-android with Apache License 2.0 | 4 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.item_delete: final int checkedItemPosition = listView.getCheckedItemPosition(); // Change the icon to download icon immediately final View rowView = listView.getChildAt(checkedItemPosition - listView.getFirstVisiblePosition()); if (rowView != null) { // rowView will be null, if the user scrolls away from the checked item ((IconImageView) rowView.findViewById(R.id.bulk_download)).setIcon(FontAwesomeIcons.fa_download); } final CourseOutlineAdapter.SectionRow rowItem = adapter.getItem(checkedItemPosition); final List<CourseComponent> videos = rowItem.component.getVideos(true); final int totalVideos = videos.size(); if (isOnCourseOutline) { environment.getAnalyticsRegistry().trackSubsectionVideosDelete( courseData.getCourse().getId(), rowItem.component.getId()); } else { environment.getAnalyticsRegistry().trackUnitVideoDelete( courseData.getCourse().getId(), rowItem.component.getId()); } /* The android docs have NOT been updated yet, but if you jump into the source code you'll notice that the parameter to the method setDuration(int duration) can either be one of LENGTH_SHORT, LENGTH_LONG, LENGTH_INDEFINITE or a custom duration in milliseconds. https://stackoverflow.com/a/30552666 https://github.com/material-components/material-components-android/commit/2cb77c9331cc3c6a5034aace0238b96508acf47d */ @SuppressLint("WrongConstant") final Snackbar snackbar = Snackbar.make(listView, getResources().getQuantityString(R.plurals.delete_video_snackbar_msg, totalVideos, totalVideos), SNACKBAR_SHOWTIME_MS); snackbar.setAction(R.string.label_undo, new View.OnClickListener() { @Override public void onClick(View v) { // No need of implementation as we'll handle the action in SnackBar's // onDismissed callback. } }); snackbar.addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>() { @Override public void onDismissed(Snackbar transientBottomBar, int event) { super.onDismissed(transientBottomBar, event); // SnackBar is being dismissed by any action other than its action button's press if (event != DISMISS_EVENT_ACTION) { final IStorage storage = environment.getStorage(); for (CourseComponent video : videos) { final VideoBlockModel videoBlockModel = (VideoBlockModel) video; final DownloadEntry downloadEntry = videoBlockModel.getDownloadEntry(storage); if (downloadEntry.isDownloaded()) { // This check is necessary because, this callback gets // called multiple times when SnackBar is about to dismiss // and the activity finishes storage.removeDownload(downloadEntry); } else { return; } } } else { if (isOnCourseOutline) { environment.getAnalyticsRegistry().trackUndoingSubsectionVideosDelete( courseData.getCourse().getId(), rowItem.component.getId()); } else { environment.getAnalyticsRegistry().trackUndoingUnitVideoDelete( courseData.getCourse().getId(), rowItem.component.getId()); } } adapter.notifyDataSetChanged(); } }); snackbar.show(); mode.finish(); return true; default: return false; } }
Example 11
Source File: EventListActivity.java From trackworktime with GNU General Public License v3.0 | 4 votes |
@Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_item_delete: AlertDialog.Builder alert = new AlertDialog.Builder(EventListActivity.this); alert.setTitle(getString(R.string.delete_event)); alert.setMessage(getString(R.string.really_delete_event)); alert.setPositiveButton(getString(R.string.ok), (dialog, whichButton) -> { for (int i = events.size(); i >= 0; i--) { if (myMultiSelector.isSelected(i, 0)) { Event event = events.remove(i); // delete event in DB boolean success = dao.deleteEvent(event); // we have to call this manually when using the DAO directly: timerManager.updateWeekSum(week); Basics.getInstance().safeCheckPersistentNotification(); if (success) { Logger.debug("deleted event with ID {}", event.getId()); } else { Logger.warn("could not delete event with ID {}", event.getId()); } myRecyclerView.getAdapter().notifyItemRemoved(i); } } myMultiSelector.clearSelections(); }); alert.setNegativeButton(getString(R.string.cancel), (dialog, which) -> { // do nothing }); alert.show(); actionMode.finish(); return true; default: return false; } }