List of usage examples for android.view ContextMenu findItem
public MenuItem findItem(int id);
From source file:com.xabber.android.ui.helper.ContextMenuHelper.java
private static void setContactContextMenuActions(final FragmentActivity activity, final UpdatableAdapter adapter, ContextMenu menu, final String account, final String user) { menu.findItem(R.id.action_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/* ww w . j a v a 2 s.co m*/ public boolean onMenuItemClick(MenuItem item) { MessageManager.getInstance().openChat(account, user); activity.startActivity(ChatViewer.createSpecificChatIntent(activity, account, user)); return true; } }); menu.findItem(R.id.action_edit_conference).setIntent(ConferenceAdd.createIntent(activity, account, user)); menu.findItem(R.id.action_delete_conference) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { MUCDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "MUC_DELETE"); return true; } }); menu.findItem(R.id.action_join_conference) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { MUCManager.getInstance().joinRoom(account, user, true); return true; } }); menu.findItem(R.id.action_leave_conference) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { MUCManager.getInstance().leaveRoom(account, user); MessageManager.getInstance().closeChat(account, user); NotificationManager.getInstance().removeMessageNotification(account, user); adapter.onChange(); return true; } }); menu.findItem(R.id.action_contact_info).setIntent(ContactEditor.createIntent(activity, account, user)); menu.findItem(R.id.action_edit_contact_groups).setIntent(GroupEditor.createIntent(activity, account, user)); menu.findItem(R.id.action_delete_contact) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { ContactDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "CONTACT_DELETE"); return true; } }); menu.findItem(R.id.action_close_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { MessageManager.getInstance().closeChat(account, user); NotificationManager.getInstance().removeMessageNotification(account, user); adapter.onChange(); return true; } }); menu.findItem(R.id.action_request_subscription) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { try { PresenceManager.getInstance().requestSubscription(account, user); } catch (NetworkException e) { Application.getInstance().onError(e); } return true; } }); menu.findItem(R.id.action_accept_subscription) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { try { PresenceManager.getInstance().acceptSubscription(account, user); } catch (NetworkException e) { Application.getInstance().onError(e); } activity.startActivity(GroupEditor.createIntent(activity, account, user)); return true; } }); menu.findItem(R.id.action_discard_subscription) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { try { PresenceManager.getInstance().discardSubscription(account, user); } catch (NetworkException e) { Application.getInstance().onError(e); } return true; } }); }
From source file:com.xabber.android.ui.helper.ContextMenuHelper.java
private static void setContactContextMenuItemsVisibilty(AbstractContact abstractContact, ContextMenu menu, String account, String user) { // all menu items are visible by default // it allows to hide items in xml file without touching code if (!MUCManager.getInstance().hasRoom(account, user)) { // is not conference menu.findItem(R.id.action_edit_conference).setVisible(false); menu.findItem(R.id.action_delete_conference).setVisible(false); menu.findItem(R.id.action_leave_conference).setVisible(false); menu.findItem(R.id.action_join_conference).setVisible(false); if (!MessageManager.getInstance().hasActiveChat(account, user)) { menu.findItem(R.id.action_close_chat).setVisible(false); }/*from w ww .ja va 2 s . c o m*/ if (abstractContact.getStatusMode() != StatusMode.unsubscribed) { menu.findItem(R.id.action_request_subscription).setVisible(false); } } else { // is conference menu.findItem(R.id.action_contact_info).setVisible(false); menu.findItem(R.id.action_edit_contact_groups).setVisible(false); menu.findItem(R.id.action_delete_contact).setVisible(false); menu.findItem(R.id.action_close_chat).setVisible(false); menu.findItem(R.id.action_request_subscription).setVisible(false); if (MUCManager.getInstance().inUse(account, user)) { menu.findItem(R.id.action_edit_conference).setVisible(false); } if (MUCManager.getInstance().isDisabled(account, user)) { menu.findItem(R.id.action_leave_conference).setVisible(false); } else { menu.findItem(R.id.action_join_conference).setVisible(false); } } if (!PresenceManager.getInstance().hasSubscriptionRequest(account, user)) { menu.findItem(R.id.action_accept_subscription).setVisible(false); menu.findItem(R.id.action_discard_subscription).setVisible(false); } }
From source file:org.klnusbaum.udj.PlaylistFragment.java
private void setupOwnerContext(boolean isCurrentlyPlaying, ContextMenu menu, MenuInflater inflater) { inflater.inflate(R.menu.owner_playlist_context, menu); if (isCurrentlyPlaying) { menu.findItem(R.id.set_current_song).setEnabled(false); menu.findItem(R.id.remove_song).setEnabled(false); }//from ww w . j av a 2 s.c o m }
From source file:eu.trentorise.smartcampus.eb.fragments.ExperiencesListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) { menu.setHeaderTitle(R.string.exp_menu_header); android.view.MenuInflater inflater = getSherlockActivity().getMenuInflater(); inflater.inflate(R.menu.exp_list_menu, menu); MenuItem item = menu.findItem(R.id.expmenu_share); if (item != null) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); Experience exp = experiencesList.get(info.position); item.setEnabled(exp.getEntityId() > 0).setVisible(exp.getEntityId() > 0); }/*from w ww . j av a2 s. c o m*/ }
From source file:org.videolan.myvlc.core.widget.AudioMiniPlayerFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.audio_player_mini, menu); MenuItem pp = menu.findItem(R.id.play_pause); if (mAudioPlayerControl.isPlaying()) { pp.setTitle(R.string.pause);/* www . jav a 2 s.c o m*/ } else { pp.setTitle(R.string.play); } }
From source file:com.josecarlos.couplecounters.MainActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { getMenuInflater().inflate(R.menu.menu_counter, menu); MenuItem item = (MenuItem) menu.findItem(R.id.counter_change); final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (listAdapter.getItem(info.position).isCommon()) { item.setTitle("make individual counter"); } else// ww w .j a v a 2 s. c o m item.setTitle("make common counter"); super.onCreateContextMenu(menu, v, menuInfo); }
From source file:org.peterbaldwin.vlcremote.fragment.BrowseFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.browse_context, menu); menu.findItem(R.id.browse_context_open).setVisible(isDirectory(menuInfo)); menu.findItem(R.id.browse_context_stream).setVisible(!isDirectory(menuInfo)); }
From source file:com.example.zayankovsky.homework.ui.ImageDetailActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.context_menu, menu); switch (mSectionNumber) { case 0:/*from w w w . j a va 2 s. c o m*/ menu.findItem(R.id.save).setVisible(false); case 2: menu.findItem(R.id.browser).setVisible(false); } }
From source file:org.tvheadend.tvhclient.fragments.TimerRecordingListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); activity.getMenuInflater().inflate(R.menu.recording_context_menu, menu); (menu.findItem(R.id.menu_play)).setVisible(false); (menu.findItem(R.id.menu_record_cancel)).setVisible(false); (menu.findItem(R.id.menu_search_imdb)).setVisible(false); (menu.findItem(R.id.menu_search_epg)).setVisible(false); // Get the currently selected program from the list where the context // menu has been triggered AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; TimerRecording rec = adapter.getItem(info.position); menu.setHeaderTitle((rec.name.length() > 0) ? rec.name : rec.title); }
From source file:org.gateshipone.malp.application.fragments.serverfragments.PlaylistTracksFragment.java
/** * Create the context menu.//w ww . j a v a2 s.c o m */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.context_menu_track, menu); // Enable the remove from list action menu.findItem(R.id.action_remove_from_list).setVisible(true); }