List of usage examples for android.widget PopupMenu PopupMenu
public PopupMenu(Context context, View anchor)
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
private void showfilterMenu() { View p = findViewById(R.id.anchorer); progressbar.setVisibility(View.GONE); final PopupMenu popup = new PopupMenu(this, p); //Inflating the Popup using xml file popup.getMenuInflater().inflate(R.menu.filter, popup.getMenu()); for (int i = 0; i < popup.getMenu().size(); i++) { MenuItem item = popup.getMenu().getItem(i); String countstr = "0"; switch (item.getItemId()) { case R.id.filter_no_filter: countstr = countFilterNofilter(); break; case R.id.filter_no_data: countstr = countFilterNodata(); break; case R.id.filter_valid_reading: countstr = countFilterValid(); break; case R.id.filter_hilow: countstr = countFilterHilow(); break; case R.id.filter_maneh: countstr = countFilterManeh(); break; case R.id.filter_inspection: countstr = countFilterInspection(); break; case R.id.filter_register_field: countstr = countFilterRegisterField(); break; case R.id.filter_not_register_field: countstr = countFilterRegisterNotField(); break; }/*www . jav a 2 s .com*/ item.setTitle(item.getTitle() + "\t" + countstr); } //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.filter_no_filter: filterNofilter(); break; case R.id.filter_no_data: filterNodata(); break; case R.id.filter_valid_reading: filterValid(); break; case R.id.filter_hilow: filterHilow(); break; case R.id.filter_maneh: //filterManeh(); showManehMenu(); break; case R.id.filter_inspection: filterInspection(); break; case R.id.filter_register_field: filterRegisterField(); break; case R.id.filter_not_register_field: filterRegisterNotField(); break; } return true; } }); final Handler handler1 = new Handler(); progressbar.setVisibility(View.GONE); //android.R.attr.progressBarStyleLarge handler1.postDelayed(new Runnable() { @Override public void run() { popup.show(); } }, 100); }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
private void showManehMenu() { View p = findViewById(R.id.anchorer); progressbar.setVisibility(View.GONE); final PopupMenu popup = new PopupMenu(this, p); //Inflating the Popup using xml file for (ManehCode m : CommonPlace.manehCodes) { if (!m.Maneh_fldCode.equals("0")) { int cnt = ReadingListDetailDA.getInstance(this).getCount("HeaderID=? and fldManehCodeNow=?", "", new String[] { CommonPlace.currentReadingList.id + "", m.Maneh_fldCode }); popup.getMenu().add(0, Integer.parseInt(m.Maneh_fldCode), 0, m.fldTiltle + "\t" + cnt); }/*from w ww . jav a 2 s .c om*/ } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { filterManeh(item.getItemId(), item.getTitle().toString()); return true; } }); final Handler handler1 = new Handler(); progressbar.setVisibility(View.GONE); //android.R.attr.progressBarStyleLarge handler1.postDelayed(new Runnable() { @Override public void run() { popup.show(); } }, 100); }
From source file:com.tct.mail.browse.MessageHeaderView.java
/** * Handles clicks on either views or menu items. View parameter can be null * for menu item clicks.//w w w . j av a2s.co m */ public boolean onClick(final View v, final int id) { if (mMessage == null) { LogUtils.i(LOG_TAG, "ignoring message header tap on unbound view"); return false; } boolean handled = true; // TS: zhaotianyong 2015-05-11 EMAIL BUGFIX_998470 MOD_S boolean mailDownloadPartial = (mMessage != null && mMessage.msgFlagLoaded == EmailContent.Message.FLAG_LOADED_PARTIAL); if (id == R.id.reply) { if (mailDownloadPartial) { //[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,08/05/2016,2635083 Utility.showShortToast(getContext(), getResources().getString(R.string.mail_not_download_completely)); return true; } ComposeActivity.reply(getContext(), getAccount(), mMessage); } else if (id == R.id.reply_all) { if (mailDownloadPartial) { //[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,08/05/2016,2635083 Utility.showShortToast(getContext(), getResources().getString(R.string.mail_not_download_completely)); return true; } ComposeActivity.replyAll(getContext(), getAccount(), mMessage); } else if (id == R.id.forward) { if (mailDownloadPartial) { //[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,08/05/2016,2635083 Utility.showShortToast(getContext(), getResources().getString(R.string.mail_not_download_completely)); return true; } // TS: zhaotianyong 2015-05-11 EMAIL BUGFIX_998470 MOD_E // TS: zhaotianyong 2015-05-08 EMAIL BUGFIX_988459 MOD_S EmailContent.Attachment[] att = EmailContent.Attachment.restoreAttachmentsWithMessageId(getContext(), mMessage.id); boolean allAttachmentsDownloaded = ComposeActivity.allAttachmentIsDownload(att); //TS: zheng.zou 2015-11-03 EMAIL BUGFIX_858353 MOD_S boolean supportSmartForward = ComposeActivity.supportSmartForward(getAccount()); if (!allAttachmentsDownloaded && !supportSmartForward) { //TS: zheng.zou 2015-11-03 EMAIL BUGFIX_858353 MOD_E ForwardDialogFragment f = ForwardDialogFragment.newInstance(getAccount(), mMessage); f.displayDialog(mCallbacks.getFragmentManager()); } else { ComposeActivity.forward(getContext(), getAccount(), mMessage); } // TS: zhaotianyong 2015-05-08 EMAIL BUGFIX_988459 MOD_E // TS: tianjing.su 2016-02-29 EMAIL BUGFIX-1595495 MOD_S } else if (id == R.id.save_group) { String[] fromMails = Address.addressParse(mFrom); String[] toMails = Address.addressParse(mTo); String[] ccMails = Address.addressParse(mCc); String[] bccMails = Address.addressParse(mBcc); MessageSaveGroupDialog.newInstance(fromMails, toMails, ccMails, bccMails).show(mFragmentManager, DIALOG_FRAGMENT_TAG); } // TS: tianjing.su 2016-02-29 EMAIL BUGFIX-1595495 MOD_E else if (id == R.id.print_message) { printMessage(); } else if (id == R.id.report_rendering_problem) { final String text = getContext().getString(R.string.report_rendering_problem_desc); ComposeActivity.reportRenderingFeedback(getContext(), getAccount(), mMessage, text + "\n\n" + mCallbacks.getMessageTransforms(mMessage)); } else if (id == R.id.report_rendering_improvement) { final String text = getContext().getString(R.string.report_rendering_improvement_desc); ComposeActivity.reportRenderingFeedback(getContext(), getAccount(), mMessage, text + "\n\n" + mCallbacks.getMessageTransforms(mMessage)); } else if (id == R.id.edit_draft) { ComposeActivity.editDraft(getContext(), getAccount(), mMessage); } else if (id == R.id.overflow) { if (mPopup == null) { mPopup = new PopupMenu(getContext(), v); mPopup.getMenuInflater().inflate(R.menu.message_header_overflow_menu, mPopup.getMenu()); // TS: tianjing.su 2016-02-29 EMAIL BUGFIX-1595495 ADD_S mPopup.getMenu().findItem(R.id.save_group) .setVisible(PLFUtils.getBoolean(getContext(), "feature_email_save_group")); // TS: tianjing.su 2016-02-29 EMAIL BUGFIX-1595495 ADD_E mPopup.setOnMenuItemClickListener(this); } final boolean defaultReplyAll = getAccount().settings.replyBehavior == UIProvider.DefaultReplyBehavior.REPLY_ALL; final Menu m = mPopup.getMenu(); // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 MOD_S //Note: check whether support Reply all //if support, show it, not support, hide it. //m.findItem(R.id.reply).setVisible(defaultReplyAll); //m.findItem(R.id.reply_all).setVisible(!defaultReplyAll); // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 MOD_E m.findItem(R.id.reply_all).setVisible(isSupportReplyAll(mMessage)); m.findItem(R.id.print_message).setVisible(Utils.isRunningKitkatOrLater()); final boolean reportRendering = ENABLE_REPORT_RENDERING_PROBLEM && mCallbacks.supportsMessageTransforms(); m.findItem(R.id.report_rendering_improvement).setVisible(reportRendering); m.findItem(R.id.report_rendering_problem).setVisible(reportRendering); mPopup.show(); } else if (id == R.id.send_date || id == R.id.hide_details || id == R.id.details_expanded_content) { toggleMessageDetails(); } else if (id == R.id.upper_header) { toggleExpanded(); } else if (id == R.id.show_pictures_text) { handleShowImagePromptClick(v); //[FEATURE]-MOD-BEGIN by TSCD.chao zhang,04/25/2014,FR 631895(porting from FR487417) } else if (id == R.id.msg_remain_btn) { doLoadMsgBackground(mMessage); //[FEATURE]-MOD-END by TSCD.chao zhang } else { LogUtils.i(LOG_TAG, "unrecognized header tap: %d", id); handled = false; } if (handled && id != R.id.overflow) { Analytics.getInstance().sendMenuItemEvent(Analytics.EVENT_CATEGORY_MENU_ITEM, id, "message_header", 0); } return handled; }
From source file:com.gxapplications.android.gxsuite.launcher.Launcher.java
public void onLongClickAppsTab(View v) { final PopupMenu popupMenu = new PopupMenu(this, v); final Menu menu = popupMenu.getMenu(); popupMenu.inflate(R.menu.apps_tab);/*from www.j a va 2 s .c o m*/ AppsCustomizePagedView.SortMode sortMode = mAppsCustomizeContent.getSortMode(); AppsCustomizePagedView.SortModeFirst sortModeFirst = mAppsCustomizeContent.getSortModeFirst(); if (sortMode == AppsCustomizePagedView.SortMode.Title) { menu.findItem(R.id.apps_sort_title).setChecked(true); } else if (sortMode == AppsCustomizePagedView.SortMode.InstallDate) { menu.findItem(R.id.apps_sort_install_date).setChecked(true); } if (sortModeFirst == AppsCustomizePagedView.SortModeFirst.None) { menu.findItem(R.id.apps_sort_none_first).setChecked(true); } else if (sortModeFirst == AppsCustomizePagedView.SortModeFirst.Google) { menu.findItem(R.id.apps_sort_google_first).setChecked(true); } else if (sortModeFirst == AppsCustomizePagedView.SortModeFirst.StockApps) { menu.findItem(R.id.apps_sort_stock_apps_first).setChecked(true); } else if (sortModeFirst == AppsCustomizePagedView.SortModeFirst.DownloadedApps) { menu.findItem(R.id.apps_sort_downloaded_apps_first).setChecked(true); } popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.apps_sort_title: mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.Title); break; case R.id.apps_sort_install_date: mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.InstallDate); break; case R.id.apps_sort_none_first: mAppsCustomizeContent.setSortModeFirst(AppsCustomizePagedView.SortModeFirst.None); break; case R.id.apps_sort_google_first: mAppsCustomizeContent.setSortModeFirst(AppsCustomizePagedView.SortModeFirst.Google); break; case R.id.apps_sort_stock_apps_first: mAppsCustomizeContent.setSortModeFirst(AppsCustomizePagedView.SortModeFirst.StockApps); break; case R.id.apps_sort_downloaded_apps_first: mAppsCustomizeContent.setSortModeFirst(AppsCustomizePagedView.SortModeFirst.DownloadedApps); break; } return true; } }); popupMenu.show(); }