List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:org.gateshipone.odyssey.fragments.ArtistAlbumsFragment.java
/** * Hook called when an menu item in the context menu is selected. * * @param item The menu item that was selected. * @return True if the hook was consumed here. *///from w ww.ja v a 2 s. com @Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (info == null) { return super.onContextItemSelected(item); } switch (item.getItemId()) { case R.id.fragment_artist_albums_action_enqueue: enqueueAlbum(info.position); return true; case R.id.fragment_artist_albums_action_play: playAlbum(info.position); return true; default: return super.onContextItemSelected(item); } }
From source file:org.peterbaldwin.vlcremote.fragment.BrowseFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { ContextMenuInfo menuInfo = item.getMenuInfo(); if (menuInfo instanceof AdapterContextMenuInfo) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; if (info.position < mAdapter.getCount()) { File file = mAdapter.getItem(info.position); switch (item.getItemId()) { case R.id.browse_context_open: openDirectory(file);//from www . jav a 2s . c o m return true; case R.id.browse_context_play: getMediaServer().status().command.input.play(file.getMrl(), file.getOptions()); return true; case R.id.browse_context_stream: getMediaServer().status().command.input.play(file.getMrl(), file.getStreamingOptions()); Intent intent = file.getIntentForStreaming(getMediaServer().getAuthority()); startActivity(intent); return true; case R.id.browse_context_enqueue: getMediaServer().status().command.input.enqueue(file.getMrl()); // delay reloading playlist to give vlc time to queue and read metadata ((Reloader) getActivity()).reloadDelayed(Tags.FRAGMENT_PLAYLIST, null, 100); return true; } } } return super.onContextItemSelected(item); }
From source file:itesm.mx.golpedecalor.SelectGroupActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int id = item.getItemId(); // Si se elimina se llama a la funcin de eliminar en DBO if (id == R.id.delete) { //(grupos.get(info.position)).getId() //Toast.makeText(getApplicationContext(), "DELETE " + nombres.get(info.position), Toast.LENGTH_LONG).show(); boolean deleted = dbo.deleteGroup((grupos.get(info.position)).getId()); nombres.remove(info.position);//from w w w . j a v a 2s. c o m adapter.notifyDataSetChanged(); return true; } return super.onContextItemSelected(item); }
From source file:com.example.android.notepad.NotesList.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info; try {/*from ww w . ja v a2 s. c o m*/ info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { Log.e(TAG, "bad menuInfo", e); return false; } switch (item.getItemId()) { case MENU_ITEM_DELETE: { // Delete the note that the context menu is for Uri noteUri = ContentUris.withAppendedId(getIntent().getData(), info.id); getContentResolver().delete(noteUri, null, null); return true; } } return false; }
From source file:liqui.droid.activity.LQFBListCached.java
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case DELETE_ID: AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); getContentResolver().delete(Uri.parse(DBSystemProvider.LQFBS_CONTENT_URI + "/" + info.id), null, null); return true; case DUPLICATE_ID: AdapterContextMenuInfo info2 = (AdapterContextMenuInfo) item.getMenuInfo(); Cursor c = getContentResolver().query(Uri.parse(DBSystemProvider.LQFBS_CONTENT_URI + "/" + info2.id), null, null, null, null); c.moveToFirst();//from w w w . j ava 2 s. c o m ContentValues values = new ContentValues(); values.put(DBSystem.TableLQFBs.COLUMN_NAME, c.getString(c.getColumnIndex(DBSystem.TableLQFBs.COLUMN_NAME))); values.put(DBSystem.TableLQFBs.COLUMN_URL, c.getString(c.getColumnIndex(DBSystem.TableLQFBs.COLUMN_URL))); values.put(DBSystem.TableLQFBs.COLUMN_WEB_URL, c.getString(c.getColumnIndex(DBSystem.TableLQFBs.COLUMN_WEB_URL))); values.put(DBSystem.TableLQFBs.COLUMN_API_KEY, c.getString(c.getColumnIndex(DBSystem.TableLQFBs.COLUMN_API_KEY))); c.close(); getContentResolver().insert(DBSystemProvider.LQFBS_CONTENT_URI, values); return true; } return super.onContextItemSelected(item); }
From source file:net.potterpcs.recipebook.RecipeListFragment.java
public void onEditItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); Uri uri = new Uri.Builder().scheme("content").authority("net.potterpcs.recipebook").build(); uri = ContentUris.withAppendedId(uri, info.id); // Log.i(TAG, "edit option selected, id=" + info.id); Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, uri); startActivity(intent);//from w w w. j a v a 2s. c o m }
From source file:net.potterpcs.recipebook.RecipeListFragment.java
public void onDeleteItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); // Log.i(TAG, "delete option selected, id=" + info.id); RecipeBookActivity activity = (RecipeBookActivity) getActivity(); RecipeData data = ((RecipeBook) activity.getApplication()).getData(); data.deleteRecipe(info.id);/*from w w w. java2 s .c o m*/ retrieveRecipes(); }
From source file:pl.selvin.android.listsyncsample.ui.ListsListFragment.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { switch (item.getItemId()) { case R.id.menu_list_edit: AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); Intent intent = new Intent(Intent.ACTION_EDIT, ListProvider.getHelper().getItemUri(Database.List.TABLE_NAME, menuInfo.id), getActivity(), EditListActivity.class); startActivity(intent);// w w w . j a v a 2s. co m return true; case R.id.menu_list_delete: menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); ConfirmDeleteDialog .newInstance(R.string.ui_alert_delete_list, ListProvider.getHelper().getItemUri(Database.List.TABLE_NAME, menuInfo.id)) .show(getFragmentManager(), "dialog"); return true; } return false; }
From source file:com.commonsware.cwac.loaderex.demo.ConstantsBrowserACL.java
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case DELETE_ID: AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); delete(info.id);// ww w . ja v a2 s .c om return (true); } return (super.onOptionsItemSelected(item)); }
From source file:net.potterpcs.recipebook.RecipeListFragment.java
public void onRateItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); // Log.i(TAG, "rate option selected, id=" + info.id); RecipeBookActivity activity = (RecipeBookActivity) getActivity(); FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); Recipe r = ((RecipeBook) activity.getApplication()).getData().getSingleRecipeObject(info.id); RateRecipeDialog rrd = RateRecipeDialog.newInstance(this, r.id, r.name, r.rating); rrd.show(ft, "dialog"); }