Java Code Examples for android.view.ActionMode#finish()
The following examples show how to use
android.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: SelectActionModeCallback.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { int id = item.getItemId(); if (id == R.id.select_action_menu_select_all) { mActionHandler.selectAll(); } else if (id == R.id.select_action_menu_cut) { mActionHandler.cut(); } else if (id == R.id.select_action_menu_copy) { mActionHandler.copy(); mode.finish(); } else if (id == R.id.select_action_menu_paste) { mActionHandler.paste(); } else if (id == R.id.select_action_menu_share) { mActionHandler.share(); mode.finish(); } else if (id == R.id.select_action_menu_web_search) { mActionHandler.search(); mode.finish(); } else { return false; } return true; }
Example 2
Source File: MessageAdapter.java From Conversations with GNU General Public License v3.0 | 6 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (item.getItemId() == android.R.id.button1) { int start = textView.getSelectionStart(); int end = textView.getSelectionEnd(); if (end > start) { String text = transformText(textView.getText(), start, end, false); if (onQuoteListener != null) { onQuoteListener.onQuote(text); } mode.finish(); } return true; } return false; }
Example 3
Source File: ListUnit.java From Dashchan with Apache License 2.0 | 6 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case ACTION_MENU_SELECT_ALL: { for (int i = 0; i < gridView.getCount(); i++) { gridView.setItemChecked(i, true); } selectionMode.setTitle(instance.context.getString(R.string.text_selected_format, gridView.getCount())); updateAllGalleryItemsChecked(); return true; } case ACTION_MENU_DOWNLOAD_FILES: { ArrayList<GalleryItem> galleryItems = new ArrayList<>(); for (int i = 0; i < gridView.getCount(); i++) { if (gridView.isItemChecked(i)) { galleryItems.add(gridAdapter.getItem(i)); } } instance.callback.downloadGalleryItems(galleryItems); mode.finish(); return true; } } return false; }
Example 4
Source File: SelectActionModeCallback.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { int id = item.getItemId(); if (id == R.id.select_action_menu_select_all) { mActionHandler.selectAll(); } else if (id == R.id.select_action_menu_cut) { mActionHandler.cut(); } else if (id == R.id.select_action_menu_copy) { mActionHandler.copy(); mode.finish(); } else if (id == R.id.select_action_menu_paste) { mActionHandler.paste(); } else if (id == R.id.select_action_menu_share) { mActionHandler.share(); mode.finish(); } else if (id == R.id.select_action_menu_web_search) { mActionHandler.search(); mode.finish(); } else { return false; } return true; }
Example 5
Source File: DraftFragment.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_remove) { if (removeTask == null || removeTask.getStatus() == MyAsyncTask.Status.FINISHED) { removeTask = new RemoveDraftDBTask(); removeTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); } mode.finish(); return true; } return false; }
Example 6
Source File: OverviewActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.toast: Toast.makeText(OverviewActivity.this, "Selected menu", Toast.LENGTH_LONG).show(); mode.finish(); // Action picked, so close the CAB return true; default: return false; } }
Example 7
Source File: SelectionPopupController.java From 365browser with Apache License 2.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (!isActionModeValid()) return true; int id = item.getItemId(); int groupId = item.getGroupId(); if (id == mAssistMenuItemId) { doAssistAction(); mode.finish(); } else if (id == R.id.select_action_menu_select_all) { selectAll(); } else if (id == R.id.select_action_menu_cut) { cut(); mode.finish(); } else if (id == R.id.select_action_menu_copy) { copy(); mode.finish(); } else if (id == R.id.select_action_menu_paste) { paste(); mode.finish(); } else if (id == R.id.select_action_menu_share) { share(); mode.finish(); } else if (id == R.id.select_action_menu_web_search) { search(); mode.finish(); } else if (groupId == R.id.select_action_menu_text_processing_menus) { processText(item.getIntent()); // The ActionMode is not dismissed to match the behavior with // TextView in Android M. } else { return false; } return true; }
Example 8
Source File: PadListActivity.java From padland with Apache License 2.0 | 5 votes |
/** * Called when the user selects a contextual menu item * * @param mode * @param item * @return */ @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menuitem_group: menu_group(getCheckedItemIds()); // Action picked, so close the CAB mode.finish(); return true; case R.id.menuitem_copy: menu_copy(getCheckedItemIds()); // Action picked, so close the CAB mode.finish(); return true; case R.id.menuitem_edit: menu_edit(getCheckedItemIds()); // Action picked, so close the CAB mode.finish(); return true; case R.id.menuitem_delete: AskDelete(getCheckedItemIds()); // Action picked, so close the CAB mode.finish(); return true; case R.id.menuitem_share: menu_share(getCheckedItemIds()); // Action picked, so close the CAB mode.finish(); return true; default: return false; } }
Example 9
Source File: ManageGroupActivity.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { SparseBooleanArray positions = null; ArrayList<String> checkedIdstrs = null; int itemId = item.getItemId(); if (itemId == R.id.menu_modify_group_name) { positions = getListView().getCheckedItemPositions(); checkedIdstrs = new ArrayList<String>(); String oriName = null; for (int i = 0; i < positions.size(); i++) { if (positions.get(positions.keyAt(i))) { oriName = group.getLists().get(positions.keyAt(i)).getName(); checkedIdstrs.add(group.getLists().get(positions.keyAt(i)).getIdstr()); } } ModifyGroupDialog modifyGroupDialog = new ModifyGroupDialog(oriName, checkedIdstrs.get(0)); modifyGroupDialog.setTargetFragment(ManageGroupFragment.this, 0); modifyGroupDialog.show(getFragmentManager(), ""); mode.finish(); return true; } else if (itemId == R.id.menu_remove) { positions = getListView().getCheckedItemPositions(); checkedIdstrs = new ArrayList<String>(); for (int i = 0; i < positions.size(); i++) { if (positions.get(positions.keyAt(i))) { checkedIdstrs.add(group.getLists().get(positions.keyAt(i)).getIdstr()); } } RemoveGroupDialog removeGroupDialog = new RemoveGroupDialog(checkedIdstrs); removeGroupDialog.setTargetFragment(ManageGroupFragment.this, 0); removeGroupDialog.show(getFragmentManager(), ""); mode.finish(); return true; } return false; }
Example 10
Source File: ConversationView.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menu_message_delete: deleteMessage(((MessageListItem)mLastSelectedView).getPacketId(),((MessageListItem)mLastSelectedView).getLastMessage()); mode.finish(); // Action picked, so close the CAB return true; case R.id.menu_message_share: ((MessageListItem)mLastSelectedView).exportMediaFile(); mode.finish(); // Action picked, so close the CAB return true; case R.id.menu_message_forward: ((MessageListItem)mLastSelectedView).forwardMediaFile(); mode.finish(); // Action picked, so close the CAB return true; case R.id.menu_message_nearby: ((MessageListItem)mLastSelectedView).nearbyMediaFile(); mode.finish(); // Action picked, so close the CAB return true; case R.id.menu_message_resend: resendMessage(((MessageListItem)mLastSelectedView).getLastMessage(),((MessageListItem)mLastSelectedView).getMimeType()); mode.finish(); // Action picked, so close the CAB return true; case R.id.menu_message_copy: String messageText = ((MessageListItem)mLastSelectedView).getLastMessage(); ClipboardManager clipboard = (ClipboardManager) mActivity.getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(mActivity.getString(R.string.app_name), messageText); clipboard.setPrimaryClip(clip); mode.finish(); Toast.makeText(mActivity, R.string.action_copied,Toast.LENGTH_SHORT).show(); return true; default: return false; } }
Example 11
Source File: MyListActivityActionbar.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menuitem1_show: show(); // Action picked, so close the CAB mode.finish(); return true; default: return false; } }
Example 12
Source File: EditorDelegate.java From 920-text-editor-v2 with Apache License 2.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.m_select_all: mEditText.selectAll(); break; case R.id.m_cut: mEditText.cut(); break; case R.id.m_copy: mEditText.copy(); break; case R.id.m_paste: mEditText.paste(); break; case R.id.m_find_replace: doCommand(new Command(Command.CommandEnum.FIND)); break; case R.id.m_convert_to_uppercase: case R.id.m_convert_to_lowercase: convertSelectedText(item.getItemId()); break; case R.id.m_duplication: mEditText.duplication(); break; } mode.finish(); return true; }
Example 13
Source File: FreeFlowContainer.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public void onItemCheckedStateChanged(ActionMode mode, int section, int position, long id, boolean checked) { mWrapped.onItemCheckedStateChanged(mode, section, position, id, checked); // If there are no items selected we no longer need the selection // mode. if (getCheckedItemCount() == 0) { mode.finish(); } }
Example 14
Source File: LocalLyricsFragment.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { LocalAdapter localAdapter = (LocalAdapter) megaListView.getExpandableListAdapter(); int count = (localAdapter).getMarkedCount(); if (count < 1) mode.finish(); else mode.setTitle(String.format(getResources().getQuantityString(R.plurals.action_mode_quantity, count), count)); return false; }
Example 15
Source File: FreeFlowContainer.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public void onItemCheckedStateChanged(ActionMode mode, int section, int position, long id, boolean checked) { mWrapped.onItemCheckedStateChanged(mode, section, position, id, checked); // If there are no items selected we no longer need the selection // mode. if (getCheckedItemCount() == 0) { mode.finish(); } }
Example 16
Source File: CommentTextView.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { Spannable text = getText() instanceof Spannable ? (Spannable) getText() : null; if (text != null) { int selStart = getSelectionStart(), selEnd = getSelectionEnd(); int min = Math.max(0, Math.min(selStart, selEnd)), max = Math.max(0, Math.max(selStart, selEnd)); switch (item.getItemId()) { case android.R.id.copy: { StringUtils.copyToClipboard(getContext(), getPartialCommentString(text, min, max)); mode.finish(); return true; } case android.R.id.button1: { if (replyable != null) { replyable.onRequestReply(new Replyable.ReplyData(postNumber, getPartialCommentString(text, min, max))); } mode.finish(); return true; } case android.R.id.button2: { Uri uri = extractSelectedUri(); if (uri != null) { getLinkListener().onLinkClick(CommentTextView.this, null, uri, true); } mode.finish(); return true; } } } return false; }
Example 17
Source File: ContentFragment.java From androidtestdebug with MIT License | 5 votes |
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.share: shareCurrentPhoto(); actionMode.finish(); return true; } return false; }
Example 18
Source File: AccountActivity.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_remove_account) { remove(); mode.finish(); return true; } return false; }
Example 19
Source File: DirectoryFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { final SparseBooleanArray checked = mCurrentView.getCheckedItemPositions(); final ArrayList<DocumentInfo> docs = new ArrayList<>(); final int size = checked.size(); for (int i = 0; i < size; i++) { if (checked.valueAt(i)) { final Cursor cursor = mAdapter.getItem(checked.keyAt(i)); if(null != cursor) { final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor); docs.add(doc); } } } if(docs.isEmpty()){ return false; } final int id = item.getItemId(); switch (id) { case R.id.menu_open: BaseActivity.get(DirectoryFragment.this).onDocumentsPicked(docs); mode.finish(); return true; case R.id.menu_share: onShareDocuments(docs); mode.finish(); return true; case R.id.menu_copy: moveDocument(docs, false); mode.finish(); return true; case R.id.menu_cut: moveDocument(docs, true); mode.finish(); return true; case R.id.menu_delete: deleteDocument(docs, id); mode.finish(); return true; case R.id.menu_stop: stopDocument(docs, id); mode.finish(); return true; case R.id.menu_save: case R.id.menu_compress: new OperationTask(docs, id).execute(); mode.finish(); return true; case R.id.menu_select_all: int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { mCurrentView.setItemChecked(i, selectAll); } selectAll = !selectAll; Bundle params = new Bundle(); params.putInt(FILE_COUNT, count); AnalyticsManager.logEvent("select", params); return true; case R.id.menu_info: infoDocument(docs.get(0)); mode.finish(); return true; case R.id.menu_rename: renameDocument(docs.get(0)); mode.finish(); return true; default: return false; } }
Example 20
Source File: WishlistDataDetailFragment.java From MonsterHunter4UDatabase with MIT License | 4 votes |
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { int position = Integer.parseInt(mode.getTag().toString()); mode.finish(); return onItemSelected(item, position); }