use of android.view.SubMenu in project GestureViews by alexvasilkov.
the class SettingsMenu method addSubMenu.
private <T> void addSubMenu(Menu menu, T[] items, T selected, @StringRes int titleId) {
SubMenu sub = menu.addSubMenu(titleId);
sub.setGroupCheckable(Menu.NONE, true, true);
for (int i = 0; i < items.length; i++) {
MenuItem item = sub.add(Menu.NONE, titleId, i, items[i].toString());
item.setCheckable(true);
item.setChecked(items[i] == selected);
}
}
use of android.view.SubMenu in project Shuttle by timusus.
the class AlbumArtistFragment method onAlbumArtistOverflowClicked.
@Override
public void onAlbumArtistOverflowClicked(View v, AlbumArtist albumArtist) {
PopupMenu menu = new PopupMenu(AlbumArtistFragment.this.getActivity(), v);
menu.inflate(R.menu.menu_artist);
SubMenu sub = menu.getMenu().findItem(R.id.addToPlaylist).getSubMenu();
PlaylistUtils.createPlaylistMenu(sub);
menu.setOnMenuItemClickListener(MenuUtils.getAlbumArtistClickListener(getContext(), albumArtist, taggerDialog -> taggerDialog.show(getChildFragmentManager()), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> UpgradeDialog.getUpgradeDialog(getActivity()).show(), null));
menu.show();
}
use of android.view.SubMenu in project Shuttle by timusus.
the class AlbumArtistFragment method onPrepareOptionsMenu.
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
// Strip the 'asc' or 'desc' flag, we just want to know the sort type
int sortOrder = SortManager.getInstance().getArtistsSortOrder();
switch(sortOrder) {
case SortManager.ArtistSort.DEFAULT:
MenuItem sortDefault = menu.findItem(R.id.sort_default);
if (sortDefault != null) {
sortDefault.setChecked(true);
}
break;
case SortManager.ArtistSort.NAME:
MenuItem sortArtistName = menu.findItem(R.id.sort_artist_name);
if (sortArtistName != null) {
sortArtistName.setChecked(true);
}
break;
}
MenuItem sortAscending = menu.findItem(R.id.sort_ascending);
if (sortAscending != null) {
sortAscending.setChecked(SortManager.getInstance().getArtistsAscending());
}
int displayType = SettingsManager.getInstance().getArtistDisplayType();
switch(displayType) {
case ViewType.ARTIST_LIST:
MenuItem viewAsList = menu.findItem(R.id.view_as_list);
if (viewAsList != null) {
viewAsList.setChecked(true);
}
break;
case ViewType.ARTIST_GRID:
MenuItem viewAsGrid = menu.findItem(R.id.view_as_grid);
if (viewAsGrid != null) {
viewAsGrid.setChecked(true);
}
break;
case ViewType.ARTIST_CARD:
MenuItem viewAsGridCard = menu.findItem(R.id.view_as_grid_card);
if (viewAsGridCard != null) {
viewAsGridCard.setChecked(true);
}
break;
case ViewType.ARTIST_PALETTE:
MenuItem viewAsGridPalette = menu.findItem(R.id.view_as_grid_palette);
if (viewAsGridPalette != null) {
viewAsGridPalette.setChecked(true);
}
break;
}
MenuItem gridMenuItem = menu.findItem(MENU_GRID_SIZE);
if (displayType == ViewType.ARTIST_LIST) {
gridMenuItem.setVisible(false);
} else {
gridMenuItem.setVisible(true);
SubMenu subMenu = gridMenuItem.getSubMenu();
if (subMenu != null) {
subMenu.findItem(SettingsManager.getInstance().getArtistColumnCount(getResources())).setChecked(true);
}
}
}
use of android.view.SubMenu in project Shuttle by timusus.
the class AlbumArtistFragment method setupContextualToolbar.
private void setupContextualToolbar() {
ContextualToolbar contextualToolbar = ContextualToolbar.findContextualToolbar(this);
if (contextualToolbar != null) {
contextualToolbar.getMenu().clear();
contextualToolbar.inflateMenu(R.menu.context_menu_general);
SubMenu sub = contextualToolbar.getMenu().findItem(R.id.addToPlaylist).getSubMenu();
if (playlistMenuDisposable != null) {
playlistMenuDisposable.dispose();
}
playlistMenuDisposable = PlaylistUtils.createUpdatingPlaylistMenu(sub).subscribe();
contextualToolbar.setOnMenuItemClickListener(MenuUtils.getAlbumArtistMenuClickListener(getContext(), () -> contextualToolbarHelper.getItems(), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> contextualToolbarHelper.finish()));
contextualToolbarHelper = new ContextualToolbarHelper<>(contextualToolbar, new ContextualToolbarHelper.Callback() {
@Override
public void notifyItemChanged(int position, SelectableViewModel viewModel) {
adapter.notifyItemChanged(position, 0);
}
@Override
public void notifyDatasetChanged() {
adapter.notifyItemRangeChanged(0, adapter.items.size(), 0);
}
});
}
}
use of android.view.SubMenu in project Shuttle by timusus.
the class AlbumFragment method onAlbumOverflowClicked.
@Override
public void onAlbumOverflowClicked(View v, Album album) {
PopupMenu menu = new PopupMenu(getContext(), v);
menu.inflate(R.menu.menu_album);
SubMenu sub = menu.getMenu().findItem(R.id.addToPlaylist).getSubMenu();
PlaylistUtils.createPlaylistMenu(sub);
menu.setOnMenuItemClickListener(MenuUtils.getAlbumMenuClickListener(getContext(), album, taggerDialog -> taggerDialog.show(getChildFragmentManager()), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> UpgradeDialog.getUpgradeDialog(getActivity()).show(), null));
menu.show();
}
Aggregations