protected void showPopupMenu(View view, final int position) { final FavoriteArticle article = (FavoriteArticle) getItem(position); PopupMenu popup = new PopupMenu(this.context, view); popup.getMenu().add(0, 0, 0, "取消收藏"); popup.show(); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case 0: WebFavoriteFragment.this.deleteFavoriteArticle(article, position); break; } return false; } }); }
@Override public void onBlockMenuClick(final View view, final StoredBlock block) { final PopupMenu popupMenu = new PopupMenu(activity, view); popupMenu.inflate(R.menu.blocks_context); popupMenu.getMenu().findItem(R.id.blocks_context_browse).setVisible(Constants.ENABLE_BROWSE); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.blocks_context_browse: final String blockHash = block.getHeader().getHashAsString(); final Uri blockExplorerUri = config.getBlockExplorer(); log.info("Viewing block {} on {}", blockHash, blockExplorerUri); startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(blockExplorerUri, "block/" + blockHash))); return true; } return false; } }); popupMenu.show(); }
public void showAudioPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio); final MenuItem backgroundAudioItem = menu.findItem(0); backgroundAudioItem.setCheckable(true); backgroundAudioItem.setChecked(enableBackgroundAudio); OnMenuItemClickListener clickListener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item == backgroundAudioItem) { enableBackgroundAudio = !item.isChecked(); return true; } return false; } }; configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO); popup.show(); }
public void showVerboseLogPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal); menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose); menu.setGroupCheckable(Menu.NONE, true, true); menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == 0) { VerboseLogUtil.setEnableAllTags(false); } else { VerboseLogUtil.setEnableAllTags(true); } return true; } }); popup.show(); }
private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener, final int trackType) { if (player == null) { return; } int trackCount = player.getTrackCount(trackType); if (trackCount == 0) { return; } popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item)) || onTrackItemClick(item, trackType); } }); Menu menu = popup.getMenu(); // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0) menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off); for (int i = 0; i < trackCount; i++) { menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, buildTrackName(player.getTrackFormat(trackType, i))); } menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true); menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true); }
@Override public void onBlockMenuClick(final View view, final StoredBlock block) { final PopupMenu popupMenu = new PopupMenu(activity, view); popupMenu.inflate(R.menu.blocks_context); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.blocks_context_browse: startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(config.getBlockExplorer(), "block/" + block.getHeader().getHashAsString()))); return true; } return false; } }); popupMenu.show(); }
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onPopupMenu(View anchor, final int position) { if (!AndroidUtil.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu()); setContextMenuItems(popupMenu.getMenu(), anchor, position); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onPopupMenu(View anchor, final int position) { if (!AndroidUtil.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu()); setContextMenuItems(popupMenu.getMenu(), anchor); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onContextPopupMenu(View anchor, final int position) { if (!AndroidUtil.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu()); MediaWrapper media = mVideoAdapter.getItem(position); if (media == null) return; setContextMenuItems(popupMenu.getMenu(), media); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
public ServerViewHolder(View view) { super(view); view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(final View v) { PopupMenu menu = ServerInfoUtil.createContextMenu(context, v, new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return ServerInfoUtil.onMenuItemClick(context, item, serverInfo, after); } }); menu.show(); return true; } }); icon = (ImageView) view.findViewById(R.id.icon); serverName = (TextView) view.findViewById(R.id.server_name); serverAddress = (TextView) view.findViewById(R.id.server_address); serverLocator = (TextView) view.findViewById(R.id.server_locator_id); serverLastConnected = (TextView) view.findViewById(R.id.server_last_connect); }
@Override public void onLongPress(MotionEvent e) { mView.setPressed(false); PopupMenu menu = new PopupMenu(mContext, mView); menu.inflate(R.menu.notification_menu); menu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if(item.getItemId() == R.id.action_info) { ControlService service = (ControlService) ControlService.getInstance(); if(service != null && service.isAttachedToWindow() && ControlService.isRunning()) { service.close(); } startApplicationDetailsActivity(mPkg); return true; } return false; } }); menu.show(); }
public void showAudioPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio); final MenuItem backgroundAudioItem = menu.findItem(0); backgroundAudioItem.setCheckable(true); backgroundAudioItem.setChecked(enableBackgroundAudio); OnMenuItemClickListener clickListener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item == backgroundAudioItem) { enableBackgroundAudio = !item.isChecked(); return true; } return false; } }; configurePopupWithTracks(popup, clickListener, FlyingPlayer.TYPE_AUDIO); popup.show(); }
public void showPopupForDP(View v, int position) { PopupMenu popup = new PopupMenu(context, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.attribute_listing_options_for_poi, popup.getMenu()); final DeceasedPerson person = deceasedPersons.get(position); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.edit: edit_DP(person); return true; case R.id.delete_entry: delete_DP(person); return true; default: return false; } } }); if (!readOnly) { popup.show(); } }
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onPopupMenu(View anchor, final int position) { if (!LibVlcUtil.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu()); setContextMenuItems(popupMenu.getMenu(), anchor, position); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onPopupMenu(View anchor, final int position) { if (!LibVlcUtil.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu()); setContextMenuItems(popupMenu.getMenu(), anchor); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onContextPopupMenu(View anchor, final int position) { if (!LibVlcUtil.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu()); Media media = mVideoAdapter.getItem(position); setContextMenuItems(popupMenu.getMenu(), media); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onPopupMenu(View anchor, final int position) { if (!Util.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.audio_list_browser, popupMenu.getMenu()); setContextMenuItems(popupMenu.getMenu(), anchor); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onContextPopupMenu(View anchor, final int position) { if (!Util.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick(); return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
public void openSectionPopup() { final String[] sections = {"All","World","Tech","Business","Entertainment","Sports","Life"}; PopupMenu popupMenu = new PopupMenu(this, findViewById(R.id.action_section)); Menu menu = popupMenu.getMenu(); for (int i=0; i<sections.length; i++) { boolean addCheck = currentSection!=null && (currentSection.equalsIgnoreCase(sections[i]) || currentSection.length()==0 && "All".equalsIgnoreCase(sections[i])); menu.add(Menu.NONE, i, Menu.NONE, addCheck ? sections[i]+"✓" : sections[i]); } popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { currentSection = item.getItemId()==0 ? null : (""+item.getTitle()).replace("✓",""); SourceListFragment slf = (SourceListFragment) getSupportFragmentManager().findFragmentById(R.id.source_list); slf.refreshList(currentSection); return false; } }); popupMenu.show(); }
public void openSortPopup() { PopupMenu popupMenu = new PopupMenu(this, findViewById(R.id.action_section)); Menu menu = popupMenu.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, sortByName ? "Name✓" : "Name"); menu.add(Menu.NONE, 1, Menu.NONE, sortByName ? "Score" : "Score✓"); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { sortByName = item.getItemId()==0; SourceListFragment slf = (SourceListFragment) getSupportFragmentManager().findFragmentById(R.id.source_list); slf.sortList(sortByName); return false; } }); popupMenu.show(); }
public void openTimePopup() { final String[] times = {"Firehose","Latest","Last Day","Last Week","Last Month"}; final String[] timeKeys = {"Firehose","Latest","Last1","Last7","Last30"}; PopupMenu popupMenu = new PopupMenu(this, findViewById(R.id.action_time)); Menu menu = popupMenu.getMenu(); for (int i=0; i<times.length; i++) { boolean addCheck = currentTime!=null && currentTime.equalsIgnoreCase(timeKeys[i]); menu.add(Menu.NONE, i, Menu.NONE, addCheck ? times[i]+"✓" : times[i]); } popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { currentTime = timeKeys[item.getItemId()]; StoryListFragment slf = (StoryListFragment) getSupportFragmentManager().findFragmentById(R.id.story_list); slf.refreshList(currentTime, currentSection, getSourceSlug()); return false; } }); popupMenu.show(); }