Java Code Examples for android.view.Menu#setGroupVisible()
The following examples show how to use
android.view.Menu#setGroupVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From Hews with MIT License | 6 votes |
void switchLoginDropdownMenu() { isLoginMenuExpanded = !isLoginMenuExpanded; Menu menu = mNavigationView.getMenu(); if (isLoginMenuExpanded) { menu.setGroupVisible(R.id.group_login, true); MenuItem menuLogin = menu.findItem(R.id.nav_login); MenuItem menuLogout = menu.findItem(R.id.nav_logout); if (SharedPrefsManager.getLoginCookie(prefs).isEmpty()) { menuLogin.setVisible(true); menuLogout.setVisible(false); } else { menuLogin.setVisible(false); menuLogout.setVisible(true); } ivExpander.setImageResource(R.drawable.expander_close); } else { menu.setGroupVisible(R.id.group_login, false); ivExpander.setImageResource(R.drawable.expander_open); } }
Example 2
Source File: WaypointList.java From Androzic with GNU General Public License v3.0 | 6 votes |
@Override public void onPrepareOptionsMenu(final Menu menu) { Androzic application = Androzic.getApplication(); MenuItem sortItem = menu.findItem(mSortMode == 0 ? R.id.action_sort_alpha : R.id.action_sort_size); sortItem.setChecked(true); Editor editor = PreferenceManager.getDefaultSharedPreferences(application).edit(); editor.putInt(getString(R.string.wpt_sort), mSortMode); editor.commit(); List<WaypointSet> sets = application.getWaypointSets(); if (sets.size() > 1) { menu.setGroupVisible(R.id.group_sets, true); menu.removeGroup(R.id.group_sets); for (int i = 1; i < sets.size(); i++) menu.add(R.id.group_sets, i, Menu.NONE, sets.get(i).name).setChecked(true); menu.setGroupCheckable(R.id.group_sets, true, false); } }
Example 3
Source File: PlaybackActivity.java From android-vlc-remote with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); boolean isBrowseVisible = isCurrentTab(TAB_BROWSE); boolean isPlaylistVisible = mTabHost == null || isCurrentTab(TAB_PLAYLIST); boolean defaultVisibility = mTabHost == null || isCurrentTab(TAB_MEDIA) || isCurrentTab(TAB_NAVIGATION); boolean isAllButtonsVisible = isBottomActionbarVisible || (mButtonsVisibleListener != null && mButtonsVisibleListener.isAllButtonsVisible()); boolean isButtonGroupVisible = isCurrentTab(TAB_MEDIA) && !isAllButtonsVisible; menu.findItem(R.id.menu_preferences).setVisible(defaultVisibility); menu.findItem(R.id.menu_help_install).setVisible(defaultVisibility); menu.findItem(R.id.menu_help_faqs).setVisible(defaultVisibility); MenuItem i = menu.findItem(R.id.menu_action_search).setVisible(isPlaylistVisible); onPrepareSearchView(i, isPlaylistVisible); menu.findItem(R.id.menu_clear_playlist).setVisible(isPlaylistVisible); menu.findItem(R.id.menu_refresh).setVisible(isPlaylistVisible); menu.findItem(R.id.menu_home).setVisible(isBrowseVisible); menu.findItem(R.id.menu_libraries).setVisible(isBrowseVisible); menu.findItem(R.id.menu_parent).setVisible(isBrowseVisible); menu.findItem(R.id.menu_set_home).setVisible(isBrowseVisible); menu.findItem(R.id.menu_text_size).setVisible(isBrowseVisible); if(isButtonGroupVisible) { Buttons.setupMenu(menu, Preferences.get(this)); } menu.setGroupVisible(R.id.group_vlc_actions, isCurrentTab(TAB_MEDIA) && !isAllButtonsVisible); return true; }
Example 4
Source File: SubsonicActivity.java From Popeens-DSub with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); SubsonicFragment currentFragment = getCurrentFragment(); if(currentFragment != null) { try { SubsonicFragment fragment = getCurrentFragment(); fragment.setContext(this); fragment.onCreateOptionsMenu(menu, menuInflater); if(isTouchscreen()) { menu.setGroupVisible(R.id.not_touchscreen, false); } } catch(Exception e) { Log.w(TAG, "Error on creating options menu", e); } } return true; }
Example 5
Source File: ChromiumTestShellActivity.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.setGroupVisible(R.id.MAIN_MENU, true); MenuItem signinItem = menu.findItem(R.id.signin); if (ChromeSigninController.get(this).isSignedIn()) signinItem.setTitle(ChromeSigninController.get(this).getSignedInAccountName()); else signinItem.setTitle(R.string.signin_sign_in); return true; }
Example 6
Source File: MainFragment.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { menuInflater.inflate(R.menu.main, menu); onFinishSetupOptionsMenu(menu); try { if (!ServerInfo.canRescanServer(context) || !UserUtil.isCurrentAdmin()) { menu.setGroupVisible(R.id.rescan_server, false); } } catch(Exception e) { Log.w(TAG, "Error on setting madsonic invisible", e); } }
Example 7
Source File: FeedsActivity.java From rss with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { // If the navigation drawer is open, hide all menu items. menu.setGroupVisible(R.id.hide_while_navigation, m_showMenuItems); return super.onPrepareOptionsMenu(menu); }
Example 8
Source File: ChromiumTestShellActivity.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.setGroupVisible(R.id.MAIN_MENU, true); MenuItem signinItem = menu.findItem(R.id.signin); if (ChromeSigninController.get(this).isSignedIn()) signinItem.setTitle(ChromeSigninController.get(this).getSignedInAccountName()); else signinItem.setTitle(R.string.signin_sign_in); return true; }
Example 9
Source File: RecyclerViewExampleActivity.java From realm-android-adapters with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; getMenuInflater().inflate(R.menu.listview_options, menu); menu.setGroupVisible(R.id.group_normal_mode, true); menu.setGroupVisible(R.id.group_delete_mode, false); return true; }
Example 10
Source File: NotesFragment.java From writeily-pro with MIT License | 5 votes |
private void showRenameContextButton(Menu menu, boolean show) { if (show) { menu.add(Menu.FIRST+1, RENAME_CONTEXT_BUTTON_ID,Menu.FIRST,R.string.rename) .setIcon(R.drawable.ic_edit_light); } else { menu.setGroupVisible(1, false); menu.removeItem(RENAME_CONTEXT_BUTTON_ID); }; }
Example 11
Source File: MainActivity.java From OpenHub with GNU General Public License v3.0 | 5 votes |
private void invalidateMainMenu(){ if(navViewStart == null){ return ; } Menu menu = navViewStart.getMenu(); if(!isAccountsAdded){ isAccountsAdded = true; List<AuthUser> users = mPresenter.getLoggedUserList(); for(AuthUser user : users){ MenuItem menuItem = menu.add(R.id.manage_accounts, Menu.NONE, 1, user.getLoginId()) .setIcon(R.drawable.ic_menu_person) .setOnMenuItemClickListener(item -> { mPresenter.toggleAccount(item.getTitle().toString()); return true; }); } } menu.setGroupVisible(R.id.my_account, isManageAccount); menu.setGroupVisible(R.id.manage_accounts, isManageAccount); menu.setGroupVisible(R.id.my, !isManageAccount); menu.setGroupVisible(R.id.repositories, !isManageAccount); menu.setGroupVisible(R.id.search, !isManageAccount); menu.setGroupVisible(R.id.setting, !isManageAccount); }
Example 12
Source File: FragmentDonate.java From privatelocation with GNU General Public License v3.0 | 5 votes |
@Override public void onPrepareOptionsMenu(Menu menu) { //hide action bar menu menu.setGroupVisible(R.id.menu_top, false); menu.setGroupVisible(R.id.menu_bottom, false); super.onPrepareOptionsMenu(menu); }
Example 13
Source File: FragmentSettings.java From privatelocation with GNU General Public License v3.0 | 5 votes |
@Override public void onPrepareOptionsMenu(Menu menu) { //hide action bar menu menu.setGroupVisible(R.id.menu_top, false); menu.setGroupVisible(R.id.menu_bottom, false); super.onPrepareOptionsMenu(menu); }
Example 14
Source File: SingleMediaActivity.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(final Menu menu) { if (!isSlideShowOn) { boolean isImage = isCurrentMediaImage(); useImageMenu = isImage; menu.setGroupVisible(R.id.only_photos_options, isImage); if (customUri) { // TODO: 05/05/18 some things can be done even with custom uri menu.setGroupVisible(R.id.on_internal_storage, false); menu.setGroupVisible(R.id.only_photos_options, false); } } return super.onPrepareOptionsMenu(menu); }
Example 15
Source File: ChannelLookupActivity.java From UTubeTV with The Unlicense | 4 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.setGroupVisible(R.id.kitkat_group, Utils.isKitKatOrNewer()); return super.onPrepareOptionsMenu(menu); }
Example 16
Source File: SubsonicFragment.java From Popeens-DSub with GNU General Public License v3.0 | 4 votes |
public void onCreateContextMenuSupport(Menu menu, MenuInflater menuInflater, UpdateView updateView, Object selected) { if(selected instanceof Entry) { Entry entry = (Entry) selected; if(entry instanceof PodcastEpisode) { if(Util.isOffline(context)) { if(entry.isVideo()) { menuInflater.inflate(R.menu.select_video_context_offline, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode_context_offline, menu); } } else { if(entry.isVideo()) { menuInflater.inflate(R.menu.select_podcast_episode_video_context, menu); } else { menuInflater.inflate(R.menu.select_podcast_episode_context, menu); } if(entry.getBookmark() == null) { menu.removeItem(R.id.bookmark_menu_delete); } if(UserUtil.canPodcast()) { String status = ((PodcastEpisode)entry).getStatus(); if("completed".equals(status)) { menu.removeItem(R.id.song_menu_server_download); } } else { menu.removeItem(R.id.song_menu_server_download); menu.removeItem(R.id.song_menu_server_delete); } } } else if (entry.isDirectory()) { if(Util.isOffline(context)) { menuInflater.inflate(R.menu.select_album_context_offline, menu); } else { menuInflater.inflate(R.menu.select_album_context, menu); } } else if(!entry.isVideo()) { if(Util.isOffline(context)) { menuInflater.inflate(R.menu.select_song_context_offline, menu); } else { menuInflater.inflate(R.menu.select_song_context, menu); if(entry.getBookmark() == null) { menu.removeItem(R.id.bookmark_menu_delete); } String songPressAction = Util.getSongPressAction(context); if(!"next".equals(songPressAction) && !"last".equals(songPressAction)) { menu.setGroupVisible(R.id.hide_play_now, false); } } } else { if(Util.isOffline(context)) { menuInflater.inflate(R.menu.select_video_context_offline, menu); } else { menuInflater.inflate(R.menu.select_video_context, menu); } } MenuItem starMenu = menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star); if(starMenu != null) { starMenu.setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); } if(!isShowArtistEnabled() || (!Util.isTagBrowsing(context) && entry.getParent() == null) || (Util.isTagBrowsing(context) && entry.getArtistId() == null)) { menu.setGroupVisible(R.id.hide_show_artist, false); } } else if(selected instanceof Artist) { Artist artist = (Artist) selected; if(Util.isOffline(context)) { menuInflater.inflate(R.menu.select_artist_context_offline, menu); } else { menuInflater.inflate(R.menu.select_artist_context, menu); menu.findItem(R.id.artist_menu_star).setTitle(artist.isStarred() ? R.string.common_unstar : R.string.common_star); } } MenuUtil.hideMenuItems(context, menu, updateView); }
Example 17
Source File: MenuActivity.java From gdk-timer-sample with Apache License 2.0 | 4 votes |
/** * Sets all menu items visible and enabled state that are in the given group. */ private static void setOptionsMenuGroupState(Menu menu, int groupId, boolean enabled) { menu.setGroupVisible(groupId, enabled); menu.setGroupEnabled(groupId, enabled); }
Example 18
Source File: MenuActivity.java From PTVGlass with MIT License | 4 votes |
/** * Sets all menu items visible and enabled state that are in the given group. */ private static void setOptionsMenuGroupState(Menu menu, int groupId, boolean enabled) { menu.setGroupVisible(groupId, enabled); menu.setGroupEnabled(groupId, enabled); }
Example 19
Source File: AudioAlbumFragment.java From VCL-Android with Apache License 2.0 | 4 votes |
private void setContextMenuItems(Menu menu, View v, int position) { menu.setGroupVisible(R.id.songs_view_only, false); menu.findItem(R.id.audio_list_browser_delete).setVisible(false); menu.setGroupVisible(R.id.phone_only, AndroidDevices.isPhone()); }
Example 20
Source File: AlbumsFragment.java From leafpicrevived with GNU General Public License v3.0 | 4 votes |
@Override public void onPrepareOptionsMenu(Menu menu) { boolean editMode = editMode(); boolean oneSelected = getSelectedCount() == 1; menu.setGroupVisible(R.id.general_album_items, !editMode); menu.setGroupVisible(R.id.edit_mode_items, editMode); menu.setGroupVisible(R.id.one_selected_items, oneSelected); menu.findItem(R.id.select_all).setTitle( getSelectedCount() == getCount() ? R.string.clear_selected : R.string.select_all); if (editMode) { menu.findItem(R.id.hide).setTitle(hidden ? R.string.unhide : R.string.hide); } else { menu.findItem(R.id.ascending_sort_order).setChecked(sortingOrder() == SortingOrder.ASCENDING); switch (sortingMode()) { case NAME: menu.findItem(R.id.name_sort_mode).setChecked(true); break; case SIZE: menu.findItem(R.id.size_sort_mode).setChecked(true); break; case DATE: default: menu.findItem(R.id.date_taken_sort_mode).setChecked(true); break; case NUMERIC: menu.findItem(R.id.numeric_sort_mode).setChecked(true); break; } } if (oneSelected) { Album selectedAlbum = mAdapter.getFirstSelectedAlbum(); menu.findItem(R.id.pin_album).setTitle(selectedAlbum.isPinned() ? getString(R.string.un_pin) : getString(R.string.pin)); menu.findItem(R.id.clear_album_cover).setVisible(selectedAlbum.hasCover()); } super.onPrepareOptionsMenu(menu); }