List of usage examples for android.view MenuItem getMenuInfo
public ContextMenuInfo getMenuInfo();
From source file:com.cl.slack.gesture.GestureBuilderActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); final NamedGesture gesture = (NamedGesture) menuInfo.targetView.getTag(); switch (item.getItemId()) { case MENU_ID_RENAME: renameGesture(gesture);//from w ww . j a v a 2 s . c om return true; case MENU_ID_REMOVE: deleteGesture(gesture); return true; } return super.onContextItemSelected(item); }
From source file:com.login.home.java
@Override public boolean onContextItemSelected(MenuItem item) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); int type = ExpandableListView.getPackedPositionType(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition); @SuppressWarnings("unchecked") HashMap<String, String> o = (HashMap<String, String>) mAdapter.getChild(groupPos, childPos); SharedPreferences settings = getSharedPreferences("pref_meetmethere", 0); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); String log = settings.getString("login", "error"); String pass = settings.getString("password", "error"); postParameters.add(new BasicNameValuePair("login", log)); postParameters.add(new BasicNameValuePair("password", pass)); postParameters.add(new BasicNameValuePair("id", o.get("id"))); if (groupPos == 1 || groupPos == 0) { switch (item.getItemId()) { case 0: postParameters.add(new BasicNameValuePair("confirmed", "1")); break; case 1: postParameters.add(new BasicNameValuePair("confirmed", "2")); break; case 2: if (groupPos == 0) { Intent intent = new Intent(home.this, event_info.class); intent.putExtra("longitude", o.get("longitude")); intent.putExtra("latitude", o.get("latitude")); intent.putExtra("willAttend", o.get("willAttend")); intent.putExtra("address", o.get("address")); intent.putExtra("id", o.get("id")); intent.putExtra("title", o.get("title")); intent.putExtra("startdate", o.get("startdate")); intent.putExtra("enddate", o.get("enddate")); intent.putExtra("address", o.get("address")); intent.putExtra("description", o.get("description")); startActivity(intent); } else if (groupPos == 1) { String friend = o.get("login"); Intent intent = new Intent(home.this, profile.class); intent.putExtra("friend", friend); intent.putExtra("yourrequest", "true"); intent.putExtra("id", o.get("id")); intent.putExtra("confirmed", "0"); startActivity(intent); }/*from ww w . ja va 2 s. c o m*/ break; } String response = null; try { if (groupPos == 1) response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_contact.php", postParameters); else response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_event.php", postParameters); String res = response.toString(); res = res.replaceAll("\\s+", ""); if (res.equals("OK")) { Intent myIntent = new Intent(home.this, home.class); startActivityForResult(myIntent, 0); } } catch (Exception e) { System.out.println("Error occured"); } } else if (groupPos == 2) { switch (item.getItemId()) { case 0: Intent intent = new Intent(home.this, event_info.class); intent.putExtra("longitude", o.get("longitude")); intent.putExtra("latitude", o.get("latitude")); intent.putExtra("willAttend", o.get("willAttend")); intent.putExtra("address", o.get("address")); intent.putExtra("id", o.get("id")); intent.putExtra("title", o.get("title")); intent.putExtra("startdate", o.get("startdate")); intent.putExtra("enddate", o.get("enddate")); intent.putExtra("address", o.get("address")); intent.putExtra("description", o.get("description")); startActivity(intent); break; case 1: Intent intent2 = new Intent(home.this, mapevent.class); intent2.putExtra("longitude", o.get("longitude")); intent2.putExtra("latitude", o.get("latitude")); intent2.putExtra("willAttend", o.get("willAttend")); intent2.putExtra("address", o.get("address")); intent2.putExtra("id", o.get("id")); intent2.putExtra("title", o.get("title")); intent2.putExtra("startdate", o.get("startdate")); intent2.putExtra("enddate", o.get("enddate")); intent2.putExtra("address", o.get("address")); intent2.putExtra("description", o.get("description")); startActivity(intent2); break; case 2: postParameters.add(new BasicNameValuePair("confirmed", "2")); String response = null; try { response = CustomHttpClient.executeHttpPost( "http://antoines.goldzoneweb.info/accept_event.php", postParameters); String res = response.toString(); res = res.replaceAll("\\s+", ""); if (res.equals("OK")) { Intent myIntent = new Intent(home.this, home.class); startActivityForResult(myIntent, 0); } } catch (Exception e) { System.out.println("Error occured"); } break; } } } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { return true; } return false; }
From source file:org.gateshipone.malp.application.fragments.serverfragments.FilesFragment.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 w w .ja va2 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.action_song_enqueue: MPDQueryHandler.addPath(((MPDFileEntry) mAdapter.getItem(info.position)).getPath()); return true; case R.id.action_song_play: MPDQueryHandler.playSong(((MPDFileEntry) mAdapter.getItem(info.position)).getPath()); return true; case R.id.action_song_play_next: MPDQueryHandler.playSongNext(((MPDFileEntry) mAdapter.getItem(info.position)).getPath()); return true; case R.id.action_add_to_saved_playlist: // open dialog in order to save the current playlist as a playlist in the mediastore ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog(); Bundle args = new Bundle(); args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true); choosePlaylistDialog.setCallback( new AddPathToPlaylist((MPDFileEntry) mAdapter.getItem(info.position), getActivity())); choosePlaylistDialog.setArguments(args); choosePlaylistDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "ChoosePlaylistDialog"); return true; case R.id.action_play_playlist: MPDQueryHandler.playPlaylist(((MPDFileEntry) mAdapter.getItem(info.position)).getPath()); return true; case R.id.action_add_playlist: MPDQueryHandler.loadPlaylist(((MPDFileEntry) mAdapter.getItem(info.position)).getPath()); return true; case R.id.action_add_directory: MPDQueryHandler.addPath(((MPDFileEntry) mAdapter.getItem(info.position)).getPath()); return true; case R.id.action_play_directory: MPDQueryHandler.playDirectory(((MPDFileEntry) mAdapter.getItem(info.position)).getPath()); return true; default: return super.onContextItemSelected(item); } }
From source file:com.money.manager.ex.investment.watchlist.WatchlistItemsFragment.java
/** * Context menu click handler. Update individual price. * @param item selected context menu item. * @return indicator whether the action is handled or not. *///from w ww .j a v a 2s. c o m @Override public boolean onContextItemSelected(android.view.MenuItem item) { ContextMenu.ContextMenuInfo menuInfo = item.getMenuInfo(); if (!(menuInfo instanceof AdapterView.AdapterContextMenuInfo)) return false; AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; // ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) ; Cursor cursor = ((StocksCursorAdapter) getListAdapter()).getCursor(); // long packedPosition = hasHeaderRow() ? info.packedPosition - 1 : info.packedPosition; int cursorPosition = hasHeaderRow() ? info.position - 1 : info.position; cursor.moveToPosition(cursorPosition); Stock stock = Stock.from(cursor); String symbol = stock.getSymbol(); boolean result = false; ContextMenuIds menuId = ContextMenuIds.get(item.getItemId()); switch (menuId) { case DownloadPrice: // Update price EventBus.getDefault().post(new PriceUpdateRequestEvent(symbol)); result = true; break; case EditPrice: // Edit price int accountId = stock.getHeldAt(); Money currentPrice = stock.getCurrentPrice(); //todo Intent intent = IntentFactory.getPriceEditIntent(getActivity()); EditPriceDialog dialog = new EditPriceDialog(); Bundle args = new Bundle(); args.putInt(EditPriceDialog.ARG_ACCOUNT, accountId); args.putString(EditPriceDialog.ARG_SYMBOL, symbol); args.putString(EditPriceDialog.ARG_PRICE, currentPrice.toString()); String dateString = new MmxDate().toIsoString(); args.putString(EditPriceDialog.ARG_DATE, dateString); dialog.setArguments(args); dialog.show(getChildFragmentManager(), "input-amount"); break; case DELETE: showDeleteConfirmationDialog(stock.getId()); break; } return result; }
From source file:com.akop.bach.fragment.xboxlive.MessagesFragment.java
@Override public boolean onContextItemSelected(MenuItem menuItem) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); if (info.targetView.getTag() instanceof ViewHolder) { ViewHolder vh = (ViewHolder) info.targetView.getTag(); String sender = vh.sender.getText().toString(); switch (menuItem.getItemId()) { case R.id.menu_mark_as_read: TaskController.getInstance().synchronizeMessage(mAccount, Messages.getUid(getActivity(), info.id), null, mListener);// w w w .ja va2 s . c o m return true; case R.id.menu_reply: MessageCompose.actionComposeMessage(getActivity(), mAccount, sender); return true; case R.id.menu_view_profile: if (XboxLive.Friends.isFriend(getActivity(), mAccount, sender)) FriendSummary.actionShow(getActivity(), mAccount, sender); return true; case R.id.menu_delete: AlertDialogFragment frag = AlertDialogFragment.newInstance(DIALOG_CONFIRM, getString(R.string.are_you_sure), getString(R.string.delete_message_from_f, sender), Messages.getUid(getActivity(), info.id)); frag.setOnOkListener(this); frag.show(getFragmentManager(), "dialog"); return true; } } return super.onContextItemSelected(menuItem); }
From source file:com.ninetwozero.battlelog.ProfileActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { // Declare... AdapterView.AdapterContextMenuInfo info; // Let's try to get some menu information via a try/catch try {/*w w w. j a v a 2 s. com*/ info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { e.printStackTrace(); return false; } switch (viewPager.getCurrentItem()) { case 2: return fragmentFeed.handleSelectedContextItem(info, item); default: break; } return true; }
From source file:ivl.android.moneybalance.ExpenseListActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item.getItemId() == ITEM_DELETE) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); int group = ExpandableListView.getPackedPositionGroup(info.packedPosition); int child = ExpandableListView.getPackedPositionChild(info.packedPosition); if (child != -1) { Expense expense = (Expense) adapter.getChild(group, child); expenseDataSource.delete(expense.getId()); refresh();/* www.j av a 2 s . com*/ } } else { return false; } return true; }
From source file:com.adamas.client.android.ui.ConnectorsFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.edit_ac: editAdamasConnector(info.position); return true; case R.id.delete_ac: deleteAdamasConnector(info.position); return true; default://from w w w .j a v a 2 s. c o m return super.onContextItemSelected(item); } }
From source file:com.remdo.app.MainActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); dm = new DatabaseHelper(this); String DeviceId = dm.getDeviceParamByName(devices[info.position], "id"); selectedItem = devices[info.position]; switch (item.getItemId()) { case R.id.editOption: //edit editDevice(Integer.parseInt(DeviceId)); return true; case R.id.deleteOption: //delete deleteDevice(Integer.parseInt(DeviceId)); return true; case R.id.newOption: CallNewDeviceActivity();// w w w. j a v a 2s . c o m return true; default: return super.onContextItemSelected(item); } }
From source file:com.ninetwozero.battlelog.PlatoonActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { // Declare... AdapterView.AdapterContextMenuInfo info; // Let's try to get some menu information via a try/catch try {// w ww. java 2s. c o m info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { e.printStackTrace(); return false; } switch (viewPager.getCurrentItem()) { case 2: return fragmentMember.handleSelectedContextItem(info, item); case 3: return fragmentFeed.handleSelectedContextItem(info, item); default: break; } return true; }