List of usage examples for android.view ActionMode finish
public abstract void finish();
From source file:at.bitfire.nophonespam.BlacklistActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_blacklist); settings = new Settings(this); list = (ListView) findViewById(R.id.numbers); list.setAdapter(adapter = new NumberAdapter(this)); list.setOnItemClickListener(this); list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); list.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override/*w w w . j av a 2s . co m*/ public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean checked) { } @Override public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { getMenuInflater().inflate(R.menu.blacklist_delete_numbers, menu); return true; } @Override public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.delete: deleteSelectedNumbers(); actionMode.finish(); return true; } return false; } @Override public void onDestroyActionMode(ActionMode actionMode) { } }); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CALL_PHONE, Manifest.permission.READ_PHONE_STATE }, 0); getLoaderManager().initLoader(0, null, this); }
From source file:org.sufficientlysecure.keychain.ui.KeyListFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void encrypt(ActionMode mode, long[] masterKeyIds) { Intent intent = new Intent(getActivity(), EncryptActivity.class); intent.setAction(EncryptActivity.ACTION_ENCRYPT); intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, masterKeyIds); // used instead of startActivity set actionbar based on callingPackage startActivityForResult(intent, 0);//from w ww . j a v a 2 s .com mode.finish(); }
From source file:org.getlantern.firetweet.fragment.BaseFiltersFragment.java
@Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case MENU_DELETE: { final Expression where = Expression.in(new Column(Filters._ID), new RawItemArray(mListView.getCheckedItemIds())); mResolver.delete(getContentUri(), where.getSQL(), null); break;/*from www .ja v a2 s .c om*/ } case MENU_INVERSE_SELECTION: { final SparseBooleanArray positions = mListView.getCheckedItemPositions(); for (int i = 0, j = mListView.getCount(); i < j; i++) { mListView.setItemChecked(i, !positions.get(i)); } return true; } default: { return false; } } mode.finish(); return true; }
From source file:org.thialfihar.android.apg.ui.KeyListFragment.java
@TargetApi(11) protected void encrypt(ActionMode mode, long[] keyRingMasterKeyIds) { Intent intent = new Intent(getActivity(), EncryptActivity.class); intent.setAction(EncryptActivity.ACTION_ENCRYPT); intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, keyRingMasterKeyIds); // used instead of startActivity set actionbar based on callingPackage startActivityForResult(intent, 0);//from www . jav a 2s .c om mode.finish(); }
From source file:org.alfresco.mobile.android.application.fragments.actions.NodeIdActions.java
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { Boolean b = false;//from w w w.j a va 2s. c o m switch (item.getItemId()) { case R.id.menu_action_sync_group_sync: sync(true); b = true; break; case R.id.menu_action_sync_group_unsync: sync(false); b = true; break; case R.id.menu_action_favorite_group_favorite: favorite(true); b = true; break; case R.id.menu_action_favorite_group_unfavorite: favorite(false); b = true; break; case R.id.menu_action_like_group_like: like(true); b = true; break; case R.id.menu_action_like_group_unlike: like(false); b = true; break; default: break; } if (b) { selectedItems.clear(); mode.finish(); } return b; }
From source file:com.gigathinking.simpleapplock.AppListFragment.java
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { AbsListView listView = ((AbsListView) getActivity().findViewById(R.id.lv_app_list)); int count = listView.getCount(); switch (item.getItemId()) { case R.id.delete_app: ArrayList<String> positions = new ArrayList<String>(); for (int i = 0; i < count; ++i) { if (listView.isItemChecked(i)) { positions.add(mList.get(i)); }/* w ww .j a v a 2 s . c o m*/ } deleteApp(positions); mode.finish(); break; case R.id.select_all: if (!allItemsChecked) { for (int i = 0; i < count; ++i) { listView.setItemChecked(i, true); } allItemsChecked = true; } else { for (int i = 0; i < count; ++i) { listView.setItemChecked(i, false); } allItemsChecked = false; } break; } return true; }
From source file:com.veniosg.dir.android.fragment.SimpleFileListFragment.java
private boolean handleSingleSelectionAction(ActionMode mode, MenuItem item) { FileHolder fItem = (FileHolder) getListAdapter().getItem(getCheckedItemPosition()); if (fItem == null) return false; DialogFragment dialog;// www .j a va2 s .c o m Bundle args; switch (item.getItemId()) { case R.id.menu_create_shortcut: mode.finish(); Utils.createShortcut(fItem, getActivity()); return true; case R.id.menu_move: mode.finish(); ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().cut(fItem); getActivity().supportInvalidateOptionsMenu(); return true; case R.id.menu_copy: mode.finish(); ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().copy(fItem); getActivity().supportInvalidateOptionsMenu(); return true; case R.id.menu_delete: mode.finish(); dialog = new SingleDeleteDialog(); dialog.setTargetFragment(SimpleFileListFragment.this, 0); args = new Bundle(); args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem); dialog.setArguments(args); dialog.show(getFragmentManager(), SingleDeleteDialog.class.getName()); return true; case R.id.menu_rename: mode.finish(); dialog = new RenameDialog(); dialog.setTargetFragment(SimpleFileListFragment.this, 0); args = new Bundle(); args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem); dialog.setArguments(args); dialog.show(getFragmentManager(), RenameDialog.class.getName()); return true; case R.id.menu_send: mode.finish(); Utils.sendFile(fItem, getActivity()); return true; case R.id.menu_details: mode.finish(); dialog = new DetailsDialog(); dialog.setTargetFragment(this, 0); args = new Bundle(); args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem); dialog.setArguments(args); dialog.show(getFragmentManager(), DetailsDialog.class.getName()); return true; case R.id.menu_compress: mode.finish(); dialog = new SingleCompressDialog(); dialog.setTargetFragment(this, 0); args = new Bundle(); args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem); dialog.setArguments(args); dialog.show(getFragmentManager(), SingleCompressDialog.class.getName()); return true; case R.id.menu_extract: mode.finish(); File extractTo = new File(fItem.getFile().getParentFile(), FileUtils.getNameWithoutExtension(fItem.getFile())); extractTo.mkdirs(); // We just extract on the current directory. If the user needs to put it in another dir, // he/she can copy/cut the file ZipService.extractTo(getActivity(), fItem, extractTo); return true; case R.id.menu_bookmark: mode.finish(); addBookmark(fItem.getFile()); return true; default: return false; } }
From source file:org.tigase.mobile.bookmarks.BookmarksActivity.java
@TargetApi(11) private void initializeContextActions() { listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { private Bookmark getBookmarkFromFlatPosition(int pos) { long packed = listView.getExpandableListPosition(pos); int child = ExpandableListView.getPackedPositionChild(packed); int group = ExpandableListView.getPackedPositionGroup(packed); return (Bookmark) adapter.getChild(group, child); }//from w ww.j a v a2s.c om @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { SparseBooleanArray selection = listView.getCheckedItemPositions(); if (item.getItemId() == R.id.edit) { for (int i = 0; i < selection.size(); i++) { if (selection.valueAt(i)) { int pos = selection.keyAt(i); Bookmark bookmark = getBookmarkFromFlatPosition(pos); editItem(bookmark); } } mode.finish(); // Action picked, so close the CAB return true; } else if (item.getItemId() == R.id.remove) { List<Bookmark> items = new ArrayList<Bookmark>(); for (int i = 0; i < selection.size(); i++) { if (selection.valueAt(i)) { int pos = selection.keyAt(i); Bookmark bookmark = getBookmarkFromFlatPosition(pos); if (bookmark != null) { items.add(bookmark); } } } removeItems(items); mode.finish(); return true; } else { return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.bookmarks_context_menu, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // TODO Auto-generated method stub } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { Menu menu = mode.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem mi = menu.getItem(i); if (mi.getItemId() == R.id.edit) { mi.setVisible(listView.getCheckedItemCount() < 2); } } } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // TODO Auto-generated method stub return true; } }); }
From source file:com.google.android.apps.mytracks.util.Api11Adapter.java
@Override public void configureListViewContextualMenu(final ListFragment activity, final ContextualActionModeCallback contextualActionModeCallback) { activity.getListView().setOnItemLongClickListener(new OnItemLongClickListener() { ActionMode actionMode;// w ww. j a v a 2 s.c o m @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, final long id) { if (actionMode != null) { // return false; } actionMode = activity.getActivity().startActionMode(new ActionMode.Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { //mode.getMenuInflater().inflate(R.menu.list_context_menu, menu); contextualActionModeCallback.onCreate(menu); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { contextualActionModeCallback.onPrepare(menu, position, id); // Return true to indicate change return true; } @Override public void onDestroyActionMode(ActionMode mode) { actionMode = null; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { mode.finish(); return contextualActionModeCallback.onClick(item.getItemId(), position, id); } }); CharSequence text = contextualActionModeCallback.getCaption(view); if (text != null) { actionMode.setTitle(text); } view.setSelected(true); return true; } }); }
From source file:foundme.uniroma2.it.professore.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); context = this; swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe_container); swipeView.setEnabled(false);/* www . jav a2 s.com*/ modeCallBack = new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.edit: if (!toEdit.equalsIgnoreCase(Variables_it.NO_COURSE)) { Intent i = new Intent(HomeActivity.this, EditCourseActivity.class); i.putExtra(Variables_it.COURSE, toEdit); i.putExtra(Variables_it.NAME, name); startActivity(i); } toEdit = null; mode.finish(); // Automatically exists the action mode, when the user selects this action break; case R.id.delete: if (!toEdit.equalsIgnoreCase(Variables_it.NO_COURSE)) { try { manageCourse(name, toEdit); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } toEdit = null; mode.finish(); break; } return false; } public void onDestroyActionMode(ActionMode mode) { viewList.setBackgroundColor(Color.TRANSPARENT); mode = null; } public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.setTitle(Variables_it.OPTION); mode.getMenuInflater().inflate(R.menu.context_menu, menu); return true; } }; Bundle passed = getIntent().getExtras(); name = passed.getString(Variables_it.NAME); TAGRead = passed.getString(Variables_it.TAG); imgUniroma2 = (ImageButton) findViewById(R.id.ivLogo2); imgUniroma2.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Variables_it.SITE_TV)); startActivity(browserIntent); } }); nfctest = (TextView) findViewById(R.id.tvNFC); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); if (mNfcAdapter == null) { Toast.makeText(this, Variables_it.NFC_UNSUPPORTED, Toast.LENGTH_LONG).show(); finish(); return; } if (!mNfcAdapter.isEnabled()) { Toast.makeText(this, Variables_it.NFC_DISABLED, Toast.LENGTH_LONG).show(); } lvCourses = (ListView) findViewById(R.id.lvCourses); if (name != null /*&& courses == null*/) { try { getCourse(true); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } profName = (TextView) findViewById(R.id.tvUserName); profName.setText(name); nfctest.setText(TAGRead); handleIntent(getIntent()); }