use of android.support.v7.widget.PopupMenu in project apps-android-wikipedia by wikimedia.
the class PageHeaderView method onEditClick.
@OnClick(R.id.view_page_header_edit_pencil)
void onEditClick() {
if (allowDescriptionEdit) {
PopupMenu menu = new PopupMenu(editPencil.getContext(), editPencil, Gravity.END, 0, R.style.PagePopupMenu);
menu.getMenuInflater().inflate(R.menu.menu_page_header_edit, menu.getMenu());
menu.setOnMenuItemClickListener(new EditMenuClickListener());
menu.show();
} else {
if (callback != null) {
callback.onEditLeadSection();
}
}
}
use of android.support.v7.widget.PopupMenu in project apps-android-wikipedia by wikimedia.
the class RemoteCompilationsFragment method showCompilationOverflowMenu.
private void showCompilationOverflowMenu(@NonNull final Compilation compilation, @NonNull View anchorView) {
PopupMenu menu = new PopupMenu(anchorView.getContext(), anchorView);
menu.getMenuInflater().inflate(R.menu.menu_remote_compilation_item, menu.getMenu());
menu.setOnMenuItemClickListener((menuItem) -> {
switch(menuItem.getItemId()) {
case R.id.menu_compilation_download:
if (DeviceUtil.isOnline()) {
if (!getDownloadObserver().isDownloading(compilation)) {
MediaDownloadReceiver.download(getContext(), compilation);
}
} else {
FeedbackUtil.showMessage(getActivity(), R.string.offline_compilation_download_device_offline);
}
return false;
default:
return false;
}
});
menu.show();
}
use of android.support.v7.widget.PopupMenu in project apps-android-commons by commons-app.
the class NearbyInfoDialog method popupMenuListener.
private void popupMenuListener() {
PopupMenu popupMenu = new PopupMenu(getActivity(), overflowButton);
popupMenu.inflate(R.menu.nearby_info_dialog_options);
MenuItem commonsArticle = popupMenu.getMenu().findItem(R.id.nearby_info_menu_commons_article);
MenuItem wikiDataArticle = popupMenu.getMenu().findItem(R.id.nearby_info_menu_wikidata_article);
commonsArticle.setEnabled(sitelinks.getCommonsLink() != null);
wikiDataArticle.setEnabled(sitelinks.getWikidataLink() != null);
popupMenu.setOnMenuItemClickListener(menuListener);
popupMenu.show();
}
use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.
the class PlaylistFragment method refreshAdapterItems.
private void refreshAdapterItems() {
PermissionUtils.RequestStoragePermissions(() -> {
if (getActivity() != null && isAdded()) {
Observable<List<Playlist>> defaultPlaylistsObservable = Observable.defer(() -> {
List<Playlist> playlists = new ArrayList<>();
Playlist podcastPlaylist = Playlist.podcastPlaylist();
if (podcastPlaylist != null) {
playlists.add(podcastPlaylist);
}
playlists.add(Playlist.recentlyAddedPlaylist);
playlists.add(Playlist.mostPlayedPlaylist);
return Observable.just(playlists);
});
Observable<List<Playlist>> playlistsObservable = DataManager.getInstance().getPlaylistsRelay();
disposable = Observable.combineLatest(defaultPlaylistsObservable, playlistsObservable, (defaultPlaylists, playlists) -> {
List<Playlist> list = new ArrayList<>();
list.addAll(defaultPlaylists);
list.addAll(playlists);
return list;
}).debounce(150, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io()).map(playlists -> {
PlaylistView.OnClickListener listener = new PlaylistView.OnClickListener() {
@Override
public void onPlaylistClick(int position, PlaylistView playlistView) {
if (playlistClickListener != null) {
playlistClickListener.onPlaylistClicked(playlistView.playlist);
}
}
@Override
public void onPlaylistOverflowClick(int position, View v, Playlist playlist) {
PopupMenu menu = new PopupMenu(PlaylistFragment.this.getActivity(), v);
MenuUtils.setupPlaylistMenu(menu, playlist);
menu.setOnMenuItemClickListener(MenuUtils.getPlaylistPopupMenuClickListener(getContext(), playlist, null));
menu.show();
}
};
return Stream.of(playlists).sorted((a, b) -> ComparisonUtils.compare(a.name, b.name)).sorted((a, b) -> ComparisonUtils.compareInt(a.type, b.type)).map(playlist -> {
PlaylistView playlistView = new PlaylistView(playlist);
playlistView.setListener(listener);
return (ViewModel) playlistView;
}).toList();
}).observeOn(AndroidSchedulers.mainThread()).subscribe(items -> {
if (items.isEmpty()) {
adapter.setItems(Collections.singletonList(new EmptyView(R.string.empty_playlist)));
} else {
adapter.setItems(items);
}
}, error -> LogUtils.logException(TAG, "Error refreshing adapter", error));
}
});
}
use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.
the class SongFragment method onSongOverflowClick.
@Override
public void onSongOverflowClick(int position, View v, Song song) {
PopupMenu menu = new PopupMenu(SongFragment.this.getActivity(), v);
MenuUtils.setupSongMenu(menu, false);
menu.setOnMenuItemClickListener(MenuUtils.getSongMenuClickListener(getContext(), song, taggerDialog -> {
if (!ShuttleUtils.isUpgraded()) {
UpgradeDialog.getUpgradeDialog(getActivity()).show();
} else {
taggerDialog.show(getChildFragmentManager());
}
}, deleteDialog -> deleteDialog.show(getChildFragmentManager()), null, null, null));
menu.show();
}
Aggregations