@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_DELETE_MESSAGE: LinphoneActivity.instance().getChatStorage().deleteMessage(chatRoom, item.getGroupId()); hideMessageBubble(item.getGroupId()); break; case MENU_SAVE_PICTURE: saveImage(item.getGroupId()); break; case MENU_COPY_TEXT: copyTextMessageToClipboard(item.getGroupId()); break; case MENU_PICTURE_SMALL: uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.SMALL); break; case MENU_PICTURE_MEDIUM: uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.MEDIUM); break; case MENU_PICTURE_LARGE: uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.LARGE); break; case MENU_PICTURE_REAL: uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.REAL); break; case MENU_RESEND_MESSAGE: resendMessage(item.getGroupId()); break; } return true; }
@Override public boolean onContextItemSelected(android.view.MenuItem item) { if (item.getGroupId() == MENU_GROUP_FILTER) { // give an initial value for the row before adding it CustomFilterCriterion criterion = filterCriteriaProvider.getAll().get(item.getItemId()); final CriterionInstance instance = new CriterionInstance(); instance.criterion = criterion; adapter.showOptionsFor( instance, new Runnable() { @Override public void run() { adapter.add(instance); updateList(); } }); return true; } // item type context item else if (item.getGroupId() == MENU_GROUP_CONTEXT_TYPE) { CriterionInstance instance = adapter.getItem(item.getOrder()); instance.type = item.getItemId(); updateList(); } // delete context item else if (item.getGroupId() == MENU_GROUP_CONTEXT_DELETE) { CriterionInstance instance = adapter.getItem(item.getOrder()); adapter.remove(instance); updateList(); } return super.onContextItemSelected(item); }
@Override public boolean onOptionsItemSelected(final MenuItem item) { long itemId; if (!isCurrentTaskListFragment()) { return false; } switch (item.getItemId()) { // --- context menu items case CONTEXT_MENU_EDIT_TASK_ID: itemId = item.getGroupId(); mListener.onTaskListItemClicked(itemId); return true; case CONTEXT_MENU_COPY_TASK_ID: itemId = item.getGroupId(); duplicateTask(itemId); return true; case CONTEXT_MENU_DELETE_TASK_ID: { itemId = item.getGroupId(); Task task = taskService.fetchById(itemId, Task.ID, Task.UUID); if (task != null) { deleteTask(task); } return true; } case CONTEXT_MENU_UNDELETE_TASK_ID: { itemId = item.getGroupId(); Task task = new Task(); task.setId(itemId); task.setDeletionDate(0L); taskService.save(task); loadTaskListContent(); return true; } case CONTEXT_MENU_PURGE_TASK_ID: { itemId = item.getGroupId(); Task task = new Task(); task.setId(itemId); TimerPlugin.updateTimer(notificationManager, taskService, getActivity(), task, false); taskDeleter.purge(itemId); loadTaskListContent(); return true; } default: return super.onOptionsItemSelected(item); } }
@Override public boolean onContextItemSelected(MenuItem menuItem) { if (menuItem.getGroupId() != getSupportTag()) { return false; } AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); Share share = (Share) listView.getItemAtPosition(info.position); switch (menuItem.getItemId()) { case R.id.share_menu_share: shareExternal(share); break; case R.id.share_menu_info: displayShareInfo(share); break; case R.id.share_menu_delete: deleteShare(share); break; case R.id.share_update_info: updateShareInfo(share); break; } return true; }
/** {@inheritDoc} */ @Override public boolean onContextItemSelected(final android.view.MenuItem item) { // Avoid leaking context menu selections if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), mArtistList, 0, true); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), mArtistList); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(mArtistList).show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long id = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), mArtistList, id); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; final String artist = mArtist.mArtistName; DeleteDialog.newInstance(artist, mArtistList, artist) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getGroupId() == 1 && mChangeFragment != null) { mChangeFragment.showEdit(null); return true; } else return false; }
private boolean onTrackItemClick(MenuItem item, int type) { if (player == null || item.getGroupId() != MENU_GROUP_TRACKS) { return false; } player.setSelectedTrack(type, item.getItemId() - ID_OFFSET); return true; }
@Override public void setGroupVisible(int group, boolean visible) { for (final MenuItem item : mMenuItems) { if (item.getGroupId() == group) { item.setVisible(visible); } } }
@Override public void setGroupEnabled(int group, boolean enabled) { for (final MenuItem item : mMenuItems) { if (item.getGroupId() == group) { item.setEnabled(enabled); } } }
@Override public boolean onContextItemSelected(android.view.MenuItem item) { if (item.getGroupId() == MAIN_ACTIVITY_CONTEXT_GROUP) { getHomeFragment().setCurrentPage(item.getItemId()); return true; } return super.onContextItemSelected(item); }
@Override public boolean onContextItemSelected(android.view.MenuItem menuItem) { if (menuItem.getGroupId() != getSupportTag()) { return false; } int activeServer = menuItem.getItemId() - MENU_ITEM_SERVER_BASE; setActiveServer(activeServer); return true; }
public boolean onOptionsItemSelected(MenuItem item) { Log.i(TAG, "called onOptionsItemSelected; selected item: " + item); if (item.getGroupId() == 1) { mOpenCvCameraView.setEffect((String) item.getTitle()); Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show(); } else if (item.getGroupId() == 2) { int id = item.getItemId(); Size resolution = mResolutionList.get(id); mOpenCvCameraView.setResolution(resolution); resolution = mOpenCvCameraView.getResolution(); String caption = Integer.valueOf(resolution.width).toString() + "x" + Integer.valueOf(resolution.height).toString(); Toast.makeText(this, caption, Toast.LENGTH_SHORT).show(); } return true; }
@Override public boolean onContextItemSelected(MenuItem menuItem) { if (menuItem.getGroupId() != getSupportTag()) { return false; } AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); Artist artist = (Artist) listView.getItemAtPosition(info.position); return onContextItemSelected(menuItem, artist); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getGroupId() == LINE_LIST_MENU_GROUP) { Intent intentMessage = new Intent(); int lineNumber = item.getItemId() - Menu.FIRST; intentMessage.putExtra("LineNumber", lineNumber); setResult(RESULT_FIRST_USER, intentMessage); this.finish(); } return super.onOptionsItemSelected(item); }
@Override public void setGroupCheckable(int group, boolean checkable, boolean exclusive) { for (final MenuItem item : mMenuItems) { if (item.getGroupId() == group) { item.setCheckable(checkable); if (exclusive) { break; } } } }
@Override public boolean onContextItemSelected(final android.view.MenuItem item) { if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), new long[] {mSelectedId}, 0, false); return true; case FragmentMenuItems.PLAY_NEXT: MusicUtils.playNext(new long[] {mSelectedId}); return true; case FragmentMenuItems.EDIT_TAGS: ApolloUtils.showTagsEditor(getActivity(), mSong); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), new long[] {mSelectedId}); return true; case FragmentMenuItems.ADD_TO_FAVORITES: FavoritesStore.getInstance(getActivity()) .addSongId(mSelectedId, mSongName, mAlbumName, mArtistName); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(new long[] {mSelectedId}) .show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long playlistId = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), new long[] {mSelectedId}, playlistId); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getActivity(), mArtistName); return true; case FragmentMenuItems.USE_AS_RINGTONE: MusicUtils.setRingtone(getActivity(), mSelectedId); return true; case FragmentMenuItems.DELETE: DeleteDialog.newInstance(mSong.mSongName, new long[] {mSelectedId}, null) .show(getFragmentManager(), "DeleteDialog"); SystemClock.sleep(10); mAdapter.notifyDataSetChanged(); getLoaderManager().restartLoader(LOADER, null, this); return true; case FragmentMenuItems.REMOVE_FROM_PLAYLIST: mAdapter.remove(mSong); mAdapter.notifyDataSetChanged(); MusicUtils.removeFromPlaylist(getActivity(), mSong.mSongId, mPlaylistId); getLoaderManager().restartLoader(LOADER, null, this); return true; default: break; } } return super.onContextItemSelected(item); }
@Override public void removeGroup(int groupId) { final List<MenuItem> items_to_remove = new ArrayList<MenuItem>(); for (final MenuItem item : mMenuItems) { if (item.hasSubMenu()) { item.getSubMenu().removeGroup(groupId); } else if (item.getGroupId() == groupId) { items_to_remove.add(item); } } mMenuItems.removeAll(items_to_remove); }
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_DELETE_MESSAGE: if (chatRoom != null) { LinphoneChatMessage message = getMessageForId(item.getGroupId()); if (message != null) { chatRoom.deleteMessage(message); invalidate(); } } break; case MENU_COPY_TEXT: copyTextMessageToClipboard(item.getGroupId()); break; case MENU_RESEND_MESSAGE: resendMessage(item.getGroupId()); break; } return true; }
@Override public boolean onContextItemSelected(MenuItem item) { final int group = item.getGroupId(); final int id = item.getItemId(); if (group == R.id.type) { setType(id); return true; } return false; }
void setExclusiveItemChecked(MenuItem item) { final int group = item.getGroupId(); final int N = mItems.size(); for (int i = 0; i < N; i++) { MenuItemImpl curItem = mItems.get(i); if (curItem.getGroupId() == group) { if (!curItem.isExclusiveCheckable()) continue; if (!curItem.isCheckable()) continue; // Check the item meant to be checked, uncheck the others (that are in the group) curItem.setCheckedInt(curItem == item); } } }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); StringBuilder sb = new StringBuilder(); sb.append("Item Menu"); sb.append("\r\n groupId: " + String.valueOf(item.getGroupId())); sb.append("\r\n itemId: " + String.valueOf(item.getItemId())); sb.append("\r\n order: " + String.valueOf(item.getOrder())); sb.append("\r\n title: " + item.getTitle()); tv.setText(sb.toString()); return super.onOptionsItemSelected(item); }
/** {@inheritDoc} */ @Override public boolean onContextItemSelected(final android.view.MenuItem item) { if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_NEXT: NowPlayingCursor queue = (NowPlayingCursor) QueueLoader.makeQueueCursor(getActivity()); queue.removeItem(mSelectedPosition); queue.close(); queue = null; MusicUtils.playNext(new long[] {mSelectedId}); refreshQueue(); return true; case FragmentMenuItems.REMOVE_FROM_QUEUE: MusicUtils.removeTrack(mSelectedId); refreshQueue(); return true; case FragmentMenuItems.ADD_TO_FAVORITES: FavoritesStore.getInstance(getActivity()) .addSongId(mSelectedId, mSongName, mAlbumName, mArtistName); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(new long[] {mSelectedId}) .show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), new long[] {mSelectedId}, mPlaylistId); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getActivity(), mArtistName); return true; case FragmentMenuItems.USE_AS_RINGTONE: MusicUtils.setRingtone(getActivity(), mSelectedId); return true; case FragmentMenuItems.DELETE: DeleteDialog.newInstance(mSong.mSongName, new long[] {mSelectedId}, null) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
@Override public boolean onContextItemSelected(android.view.MenuItem item) { if (item.getGroupId() == 1) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); long itemid = item.getItemId(); if (item.getItemId() == 0) { Log.i(TAG, "show item:" + itemid); activity.ld.runCommand_noreturn("display", String.valueOf(itemid), ""); } else if (item.getItemId() == 1) { Log.i(TAG, "remove item:" + itemid); if (activity.hosts != null) new RemoveItemTask().execute(itemid); } return true; } else { return false; } }
private void setMenuItemCheck(MenuItem menuItem) { int currentGroupId = menuItem.getGroupId(); ArrayList<Integer> allGroupsIds = new ArrayList<Integer>() { { add(R.id.top); add(R.id.bottom); } }; for (int i = 0; i < allGroupsIds.size(); ++i) { if (currentGroupId == allGroupsIds.get(i)) { navigationView.getMenu().setGroupCheckable(allGroupsIds.get(i), true, true); } else { navigationView.getMenu().setGroupCheckable(allGroupsIds.get(i), false, true); } } menuItem.setChecked(true); }
@Override public boolean onContextItemSelected(final android.view.MenuItem item) { if (item.getGroupId() == GROUP_ID) { switch (item.getItemId()) { case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(getActivity(), new long[] {mSelectedId}, 0, false); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(getActivity(), new long[] {mSelectedId}); return true; case FragmentMenuItems.ADD_TO_FAVORITES: FavoritesStore.getInstance(getActivity()) .addSongId(mSelectedId, mSongName, mAlbumName, mArtistName); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(new long[] {mSelectedId}) .show(getFragmentManager(), "CreatePlaylist"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), new long[] {mSelectedId}, mPlaylistId); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(getActivity(), mArtistName); return true; case FragmentMenuItems.USE_AS_RINGTONE: MusicUtils.setRingtone(getActivity(), mSelectedId); return true; case FragmentMenuItems.DELETE: mShouldRefresh = true; DeleteDialog.newInstance(mSong.mSongName, new long[] {mSelectedId}, null) .show(getFragmentManager(), "DeleteDialog"); return true; default: break; } } return super.onContextItemSelected(item); }
@Override public boolean onContextItemSelected(MenuItem item) { Log.e("context", "entra a la seleccion"); if (item.getGroupId() == FRAGMENT_GROUPID) { ContextMenu.ContextMenuInfo menuInfo = item.getMenuInfo(); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; // se guarda la posicion para borrar de la lv directamente y no // tener que llamar a la base de datos de nuevo itemposition = info.position; if (itemposition > 0) itemposition--; // hay que restar 1 porque la lista tiene un header final Comment comentario = listaComments.get(itemposition); switch (item.getItemId()) { /// editamos el evento asi que nos vamos a la pantalla del editor // y le pasamos el id del evento como argumento case R.id.action_borrar_comentario: // Borramos el evento AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("¿Desea borrar el comentario?"); builder.setCancelable(false); builder.setPositiveButton( "Si", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { new BorrarComentario().execute(comentario.getId()); } }); builder.setNegativeButton("No", null); builder.show(); return true; } } return super.onContextItemSelected(item); }
/** React to a selection in the option menu */ @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getGroupId() == BAND_SELECTION_MENU) { switch (item.getItemId()) { case BAND_US: mSelectedBand = FmBand.BAND_US; item.setChecked(true); break; case BAND_EU: mSelectedBand = FmBand.BAND_EU; item.setChecked(true); break; case BAND_JAPAN: mSelectedBand = FmBand.BAND_JAPAN; item.setChecked(true); break; case BAND_CHINA: mSelectedBand = FmBand.BAND_CHINA; item.setChecked(true); break; default: break; } mFmBand = new FmBand(mSelectedBand); try { mFmTransmitter.reset(); ((Button) findViewById(R.id.Transmit)).setBackgroundResource(R.drawable.transmitgobutton); ((TextView) findViewById(R.id.FrequencyTextView)).setText("----"); mFrequencyIncrement = mFmBand.getChannelOffset() / 1000; mTransmitAnimation.stop(); } catch (Exception e) { showToast("Unable to restart the FM Radio", Toast.LENGTH_LONG); } } return super.onOptionsItemSelected(item); }
@Override public int getGroupId() { return mNativeItem.getGroupId(); }
@Override public boolean onContextItemSelected(MenuItem item) { final int group = item.getGroupId(); final int id = item.getItemId(); if (group == R.id.type) { setType(LogType.getById(id)); return true; } else if (group == R.id.changebutton) { try { final LogTypeTrackable logType = LogTypeTrackable.findById(id); if (logType != null) { final LinearLayout inventView = (LinearLayout) findViewById(R.id.inventory); for (int count = 0; count < inventView.getChildCount(); count++) { final LinearLayout tbView = (LinearLayout) inventView.getChildAt(count); if (tbView == null) { return false; } final TextView tbText = (TextView) tbView.findViewById(R.id.action); if (tbText == null) { return false; } tbText.setText(res.getString(logType.resourceId) + " ▼"); } for (cgTrackableLog tb : trackables) { tb.action = logType; } tbChanged = true; return true; } } catch (Exception e) { Log.e("cgeovisit.onContextItemSelected: " + e.toString()); } } else { try { final LogTypeTrackable logType = LogTypeTrackable.findById(id); if (logType != null) { final LinearLayout tbView = (LinearLayout) findViewById(group); if (tbView == null) { return false; } final TextView tbText = (TextView) tbView.findViewById(R.id.action); if (tbText == null) { return false; } for (cgTrackableLog tb : trackables) { if (tb.id == group) { tbChanged = true; tb.action = logType; tbText.setText(res.getString(logType.resourceId) + " ▼"); Log.i("Trackable " + tb.trackCode + " (" + tb.name + ") has new action: #" + id); } } return true; } } catch (Exception e) { Log.e("cgeovisit.onContextItemSelected: " + e.toString()); } } return false; }
@Override public boolean onMenuItemClick(MenuItem item) { if (item.getGroupId() == getGroupId()) { switch (item.getItemId()) { case FragmentMenuItems.REMOVE_FROM_RECENT: RecentStore.getInstance(mActivity).removeItem(getId()); MusicUtils.refresh(); return true; case FragmentMenuItems.PLAY_SELECTION: MusicUtils.playAll(mActivity, getIdList(), 0, getSourceId(), getSourceType(), false); return true; case FragmentMenuItems.ADD_TO_QUEUE: MusicUtils.addToQueue(mActivity, getIdList(), getSourceId(), getSourceType()); return true; case FragmentMenuItems.ADD_TO_PLAYLIST: ContextMenuBuilder builder = new ContextMenuBuilder(mActivity); MusicUtils.makePlaylistMenu(mActivity, getGroupId(), builder); builder.setHeaderTitle(R.string.add_to_playlist); builder.setCallback( new MenuBuilder.Callback() { @Override public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { return onMenuItemClick(item); } @Override public void onMenuModeChange(MenuBuilder menu) { // do nothing } }); builder.show(null, null); return true; case FragmentMenuItems.NEW_PLAYLIST: CreateNewPlaylist.getInstance(getIdList()).show(mFragmentManager, "CreatePlaylist"); return true; case FragmentMenuItems.RENAME_PLAYLIST: RenamePlaylist.getInstance(getId()).show(mFragmentManager, "RenameDialog"); return true; case FragmentMenuItems.PLAYLIST_SELECTED: final long mPlaylistId = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(mActivity, getIdList(), mPlaylistId); return true; case FragmentMenuItems.MORE_BY_ARTIST: NavUtils.openArtistProfile(mActivity, getArtistName()); return true; case FragmentMenuItems.DELETE: onDeleteClicked(); return true; case FragmentMenuItems.USE_AS_RINGTONE: MusicUtils.setRingtone(mActivity, getId()); return true; case FragmentMenuItems.REMOVE_FROM_PLAYLIST: removeFromPlaylist(); return true; case FragmentMenuItems.REMOVE_FROM_QUEUE: removeFromQueue(); return true; case FragmentMenuItems.PLAY_NEXT: playNext(); return true; case FragmentMenuItems.PLAY_ALBUM: playAlbum(); return true; default: break; } } return false; }