List of usage examples for android.widget PopupMenu getMenu
public Menu getMenu()
From source file:nl.mpcjanssen.simpletask.Simpletask.java
private void updateRightDrawer() { ArrayList<String> names = new ArrayList<String>(); final ArrayList<ActiveFilter> filters = getSavedFilter(); Collections.sort(filters, new Comparator<ActiveFilter>() { public int compare(@NotNull ActiveFilter f1, @NotNull ActiveFilter f2) { return f1.getName().compareToIgnoreCase(f2.getName()); }/*from w w w . j a v a 2 s . co m*/ }); for (ActiveFilter f : filters) { names.add(f.getName()); } m_rightDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, names)); m_rightDrawerList.setChoiceMode(AbsListView.CHOICE_MODE_NONE); m_rightDrawerList.setLongClickable(true); m_rightDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mFilter = filters.get(position); Intent intent = getIntent(); mFilter.saveInIntent(intent); setIntent(intent); mFilter.saveInPrefs(TodoApplication.getPrefs()); m_adapter.setFilteredTasks(); if (m_drawerLayout != null) { m_drawerLayout.closeDrawer(Gravity.RIGHT); } finishActionmode(); updateDrawers(); } }); m_rightDrawerList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final ActiveFilter filter = filters.get(position); final String prefsName = filter.getPrefName(); PopupMenu popupMenu = new PopupMenu(Simpletask.this, view); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(@NotNull MenuItem item) { int menuid = item.getItemId(); switch (menuid) { case R.id.menu_saved_filter_delete: deleteSavedFilter(prefsName); break; case R.id.menu_saved_filter_shortcut: createFilterShortcut(filter); break; case R.id.menu_saved_filter_rename: renameSavedFilter(prefsName); break; case R.id.menu_saved_filter_update: updateSavedFilter(prefsName); break; default: break; } return true; } }); MenuInflater inflater = popupMenu.getMenuInflater(); inflater.inflate(R.menu.saved_filter, popupMenu.getMenu()); popupMenu.show(); return true; } }); }
From source file:com.filemanager.free.adapters.Recycleradapter.java
void showPopup(View v, final Layoutelements rowItem) { v.setOnClickListener(new View.OnClickListener() { @Override// www .j a v a 2 s.c om public void onClick(View view) { PopupMenu popupMenu = new PopupMenu(main.getActivity(), view); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.about: main.utils.showProps((rowItem).generateBaseFile(), rowItem.getPermissions(), main, main.ROOT_MODE); return true; case R.id.share: ArrayList<File> arrayList = new ArrayList<File>(); arrayList.add(new File(rowItem.getDesc())); main.utils.shareFiles(arrayList, main.MAIN_ACTIVITY, main.theme1, Color.parseColor(main.fabSkin)); return true; case R.id.rename: main.rename(rowItem.generateBaseFile()); return true; case R.id.cpy: MainActivity MAIN_ACTIVITY = main.MAIN_ACTIVITY; main.MAIN_ACTIVITY.MOVE_PATH = null; ArrayList<BaseFile> copies = new ArrayList<>(); copies.add(rowItem.generateBaseFile()); MAIN_ACTIVITY.COPY_PATH = copies; MAIN_ACTIVITY.supportInvalidateOptionsMenu(); return true; case R.id.cut: MainActivity MAIN_ACTIVITY1 = main.MAIN_ACTIVITY; MAIN_ACTIVITY1.COPY_PATH = null; ArrayList<BaseFile> copie = new ArrayList<>(); copie.add(rowItem.generateBaseFile()); MAIN_ACTIVITY1.MOVE_PATH = copie; MAIN_ACTIVITY1.supportInvalidateOptionsMenu(); return true; case R.id.ex: main.MAIN_ACTIVITY.mainActivityHelper.extractFile(new File(rowItem.getDesc())); return true; case R.id.book: DataUtils.addBook(new String[] { rowItem.getTitle(), rowItem.getDesc() }, true); main.MAIN_ACTIVITY.updateDrawer(); Toast.makeText(main.getActivity(), main.utils.getString(main.getActivity(), R.string.bookmarksadded), Toast.LENGTH_LONG).show(); return true; } return false; } }); popupMenu.inflate(R.menu.item_extras); String x = rowItem.getDesc().toLowerCase(); if (rowItem.isDirectory()) popupMenu.getMenu().findItem(R.id.share).setVisible(false); if (x.endsWith(".zip") || x.endsWith(".jar") || x.endsWith(".apk") || x.endsWith(".rar") || x.endsWith(".tar") || x.endsWith(".tar.gz")) popupMenu.getMenu().findItem(R.id.ex).setVisible(true); popupMenu.show(); } }); }
From source file:com.msopentech.applicationgateway.EnterpriseBrowserActivity.java
public void showSettingsPopup(View v) { try {//from ww w .ja v a2 s . c o m PopupMenu popup = new PopupMenu(this, v); MenuInflater inflater = popup.getMenuInflater(); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_connection: { showAgentsList(); return true; } case R.id.menu_sign_in_or_out: { if (mIsSigninRequired) { // Menu item in sign in mode. //TODO: showSignIn(null, true); return true; } // Clean up the session. mTraits.sessionID = null; mTraits.token = null; mTraits.agent = null; // Indicate the condition. mIsSigninRequired = true; //Remove all tabs except one. mCustomTabHost.resetTabs(); mUrlEditTextView.setText(""); mProgressBarView.setProgress(0); // Disable the reload button and set the right image for it. mReloadButtonView.setEnabled(false); mReloadButtonView.setImageResource(R.drawable.reload_button); mStatusButtonView.setImageResource(R.drawable.connection_red); // Since it's the user's intention to sign out, his // history must be dropped. PersistenceManager.dropContent(PersistenceManager.ContentType.HISTORY); return true; } // Removed from RELEASE version. Should be active for development ONLY. // case R.id.menu_advanced_router_settings: { // showAdvancedRouterSettings(null); // } default: { return false; } } } }); inflater.inflate(R.menu.settings_menu, popup.getMenu()); if (mIsSigninRequired) { MenuItem signItem = popup.getMenu().findItem(R.id.menu_sign_in_or_out); signItem.setTitle(getResources().getString(R.string.browser_menu_item_sign_in)); } // Assumes that agent always has a display name. If display name is not present agent is considered to be not connected. MenuItem agentItem = popup.getMenu().findItem(R.id.menu_connection); String status = getResources().getString(R.string.browser_menu_item_choose_connection_not_connected); if (mTraits != null && mTraits.agent != null && !TextUtils.isEmpty(mTraits.agent.getDisplayName())) { status = mTraits.agent.getDisplayName(); } Spannable span = new SpannableString( getResources().getString(R.string.browser_menu_item_choose_connection, status)); span.setSpan(new RelativeSizeSpan(0.8f), 18, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new ForegroundColorSpan(Color.GRAY), 18, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); agentItem.setTitle(span); popup.show(); } catch (final Exception e) { Utility.showAlertDialog(EnterpriseBrowserActivity.class.getSimpleName() + ".showSettingsPopup(): Failed. " + e.toString(), EnterpriseBrowserActivity.this); } }
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 v a 2 s . co 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(); }