Search in sources :

Example 21 with PopupMenu

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();
        }
    }
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu) OnClick(butterknife.OnClick)

Example 22 with PopupMenu

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();
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu)

Example 23 with PopupMenu

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();
}
Also used : MenuItem(android.view.MenuItem) PopupMenu(android.support.v7.widget.PopupMenu)

Example 24 with PopupMenu

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));
        }
    });
}
Also used : R(com.simplecity.amp_library.R) Context(android.content.Context) Bundle(android.os.Bundle) Stream(com.annimon.stream.Stream) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ArrayList(java.util.ArrayList) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) PlaylistView(com.simplecity.amp_library.ui.modelviews.PlaylistView) View(android.view.View) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) LogUtils(com.simplecity.amp_library.utils.LogUtils) LayoutInflater(android.view.LayoutInflater) Playlist(com.simplecity.amp_library.model.Playlist) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) PopupMenu(android.support.v7.widget.PopupMenu) ViewGroup(android.view.ViewGroup) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) PermissionUtils(com.simplecity.amp_library.utils.PermissionUtils) ComparisonUtils(com.simplecity.amp_library.utils.ComparisonUtils) DataManager(com.simplecity.amp_library.utils.DataManager) Nullable(android.support.annotation.Nullable) Collections(java.util.Collections) ArrayList(java.util.ArrayList) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) PlaylistView(com.simplecity.amp_library.ui.modelviews.PlaylistView) View(android.view.View) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) Playlist(com.simplecity.amp_library.model.Playlist) PlaylistView(com.simplecity.amp_library.ui.modelviews.PlaylistView) ArrayList(java.util.ArrayList) List(java.util.List) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) PopupMenu(android.support.v7.widget.PopupMenu)

Example 25 with PopupMenu

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();
}
Also used : R(com.simplecity.amp_library.R) Bundle(android.os.Bundle) Stream(com.annimon.stream.Stream) ShuffleView(com.simplecity.amp_library.ui.modelviews.ShuffleView) SongView(com.simplecity.amp_library.ui.modelviews.SongView) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MenuItem(android.view.MenuItem) Song(com.simplecity.amp_library.model.Song) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) Menu(android.view.Menu) View(android.view.View) Observable(io.reactivex.Observable) SectionedAdapter(com.simplecity.amp_library.ui.adapters.SectionedAdapter) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) LogUtils(com.simplecity.amp_library.utils.LogUtils) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) SortManager(com.simplecity.amp_library.utils.SortManager) LayoutInflater(android.view.LayoutInflater) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) PopupMenu(android.support.v7.widget.PopupMenu) SubMenu(android.view.SubMenu) ViewGroup(android.view.ViewGroup) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) PermissionUtils(com.simplecity.amp_library.utils.PermissionUtils) DataManager(com.simplecity.amp_library.utils.DataManager) Nullable(android.support.annotation.Nullable) Collections(java.util.Collections) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

PopupMenu (android.support.v7.widget.PopupMenu)142 MenuItem (android.view.MenuItem)116 View (android.view.View)86 TextView (android.widget.TextView)63 RecyclerView (android.support.v7.widget.RecyclerView)54 ImageView (android.widget.ImageView)40 Intent (android.content.Intent)32 PopupMenu (android.widget.PopupMenu)31 List (java.util.List)27 ArrayList (java.util.ArrayList)26 MenuInflater (android.view.MenuInflater)23 Menu (android.view.Menu)22 Bundle (android.os.Bundle)20 LayoutInflater (android.view.LayoutInflater)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 Context (android.content.Context)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)18 AdapterView (android.widget.AdapterView)17 DialogInterface (android.content.DialogInterface)16 ViewGroup (android.view.ViewGroup)15