use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.
the class SuggestedFragment method onAlbumOverflowClicked.
@Override
public void onAlbumOverflowClicked(View v, Album album) {
PopupMenu menu = new PopupMenu(getContext(), v);
MenuUtils.setupAlbumMenu(menu);
menu.setOnMenuItemClickListener(MenuUtils.getAlbumMenuClickListener(getContext(), album, taggerDialog -> taggerDialog.show(getChildFragmentManager()), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> UpgradeDialog.getUpgradeDialog(getActivity()).show(), null));
menu.show();
}
use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.
the class SearchPresenter method onAlbumArtistOverflowClicked.
@Override
public void onAlbumArtistOverflowClicked(View v, AlbumArtist albumArtist) {
PopupMenu menu = new PopupMenu(v.getContext(), v);
menu.inflate(R.menu.menu_artist);
menu.setOnMenuItemClickListener(MenuUtils.getAlbumArtistClickListener(v.getContext(), albumArtist, taggerDialog -> {
SearchView searchView = getView();
if (searchView != null) {
searchView.showTaggerDialog(taggerDialog);
}
}, deleteDialog -> {
SearchView searchView = getView();
if (searchView != null) {
searchView.showDeleteDialog(deleteDialog);
}
}, null, () -> {
SearchView searchView = getView();
if (searchView != null) {
searchView.showUpgradeDialog();
}
}));
menu.show();
}
use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.
the class BaseDetailFragment method onSongOverflowClick.
@Override
public void onSongOverflowClick(int position, View v, Song song) {
PopupMenu popupMenu = new PopupMenu(getContext(), v);
MenuUtils.setupSongMenu(popupMenu, showSongOverflowRemoveButton());
popupMenu.setOnMenuItemClickListener(MenuUtils.getSongMenuClickListener(getContext(), song, taggerDialog -> {
if (ShuttleUtils.isUpgraded()) {
taggerDialog.show(getChildFragmentManager());
} else {
UpgradeDialog.getUpgradeDialog(getActivity()).show();
}
}, deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> songRemoved(position, song), null, null));
popupMenu.show();
}
use of android.support.v7.widget.PopupMenu in project StreetComplete by westnordost.
the class AddRoadNameAdapter method showNameSuggestionsMenu.
private void showNameSuggestionsMenu(View v, final Map<String, Map<String, String>> roadNameSuggestionsMap, final OnRoadNameSuggestionSelected callback) {
PopupMenu m = new PopupMenu(context, v);
int i = 0;
for (Map.Entry<String, Map<String, String>> entry : roadNameSuggestionsMap.entrySet()) {
m.getMenu().add(NONE, i++, NONE, entry.getKey());
}
m.setOnMenuItemClickListener(item -> {
Map<String, String> selected = roadNameSuggestionsMap.get(item.getTitle().toString());
callback.onRoadNameSuggestionSelected(selected);
return true;
});
m.show();
}
use of android.support.v7.widget.PopupMenu in project Slide by ccrama.
the class MainActivity method openPopup.
public void openPopup() {
PopupMenu popup = new PopupMenu(MainActivity.this, findViewById(R.id.anchor), Gravity.RIGHT);
String id = ((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id;
final Spannable[] base = Reddit.getSortingSpannables(getBaseContext(), id);
for (Spannable s : base) {
MenuItem m = popup.getMenu().add(s);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
LogUtil.v("Chosen is " + item.getOrder());
int i = 0;
for (Spannable s : base) {
if (s.equals(item.getTitle())) {
break;
}
i++;
}
switch(i) {
case 0:
Reddit.setSorting(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.HOT);
reloadSubs();
break;
case 1:
Reddit.setSorting(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.NEW);
reloadSubs();
break;
case 2:
Reddit.setSorting(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.RISING);
reloadSubs();
break;
case 3:
Reddit.setSorting(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.TOP);
openPopupTime();
break;
case 4:
Reddit.setSorting(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.CONTROVERSIAL);
openPopupTime();
break;
}
return true;
}
});
popup.show();
}
Aggregations