Search in sources :

Example 26 with PopupMenu

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();
}
Also used : R(com.simplecity.amp_library.R) GridLayoutManager(android.support.v7.widget.GridLayoutManager) Bundle(android.os.Bundle) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) SuggestedDividerDecoration(com.simplecity.amp_library.ui.views.SuggestedDividerDecoration) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Song(com.simplecity.amp_library.model.Song) Optional(com.annimon.stream.Optional) RequestManager(com.bumptech.glide.RequestManager) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) LogUtils(com.simplecity.amp_library.utils.LogUtils) Playlist(com.simplecity.amp_library.model.Playlist) PopupMenu(android.support.v7.widget.PopupMenu) ViewGroup(android.view.ViewGroup) SuggestedHeaderView(com.simplecity.amp_library.ui.modelviews.SuggestedHeaderView) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) FragmentModule(com.simplecity.amp_library.dagger.module.FragmentModule) PermissionUtils(com.simplecity.amp_library.utils.PermissionUtils) Nullable(android.support.annotation.Nullable) Context(android.content.Context) SuggestedSongView(com.simplecity.amp_library.ui.modelviews.SuggestedSongView) Album(com.simplecity.amp_library.model.Album) 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) ViewType(com.simplecity.amp_library.ui.adapters.ViewType) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) SuppressLint(android.annotation.SuppressLint) SuggestedHeader(com.simplecity.amp_library.model.SuggestedHeader) Toast(android.widget.Toast) Observable(io.reactivex.Observable) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) LayoutInflater(android.view.LayoutInflater) AlbumView(com.simplecity.amp_library.ui.modelviews.AlbumView) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) PlaylistDetailFragment(com.simplecity.amp_library.ui.detail.PlaylistDetailFragment) ComparisonUtils(com.simplecity.amp_library.utils.ComparisonUtils) DataManager(com.simplecity.amp_library.utils.DataManager) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) PopupMenu(android.support.v7.widget.PopupMenu)

Example 27 with PopupMenu

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();
}
Also used : R(com.simplecity.amp_library.R) Album(com.simplecity.amp_library.model.Album) Stream(com.annimon.stream.Stream) SongView(com.simplecity.amp_library.ui.modelviews.SongView) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) NonNull(android.support.annotation.NonNull) ViewType(com.simplecity.amp_library.ui.adapters.ViewType) StringUtils(com.simplecity.amp_library.utils.StringUtils) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Song(com.simplecity.amp_library.model.Song) AlbumArtistView(com.simplecity.amp_library.ui.modelviews.AlbumArtistView) PrefixHighlighter(com.simplecity.amp_library.format.PrefixHighlighter) RequestManager(com.bumptech.glide.RequestManager) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) Header(com.simplecity.amp_library.model.Header) LogUtils(com.simplecity.amp_library.utils.LogUtils) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) Collectors(com.annimon.stream.Collectors) SingleOperator(io.reactivex.SingleOperator) PopupMenu(android.support.v7.widget.PopupMenu) TextUtils(android.text.TextUtils) AlbumView(com.simplecity.amp_library.ui.modelviews.AlbumView) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) Presenter(com.simplecity.amp_library.ui.presenters.Presenter) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) SingleObserver(io.reactivex.SingleObserver) DataManager(com.simplecity.amp_library.utils.DataManager) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) SearchHeaderView(com.simplecity.amp_library.ui.modelviews.SearchHeaderView) Nullable(android.support.annotation.Nullable) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) PopupMenu(android.support.v7.widget.PopupMenu)

Example 28 with PopupMenu

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();
}
Also used : R(com.simplecity.amp_library.R) CompletionListUpdateCallbackAdapter(com.simplecityapps.recycler_adapter.adapter.CompletionListUpdateCallbackAdapter) Bundle(android.os.Bundle) SongView(com.simplecity.amp_library.ui.modelviews.SongView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) ImageView(android.widget.ImageView) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) Random(java.util.Random) Drawable(android.graphics.drawable.Drawable) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) OnClick(butterknife.OnClick) BindView(butterknife.BindView) ColorStateList(android.content.res.ColorStateList) Song(com.simplecity.amp_library.model.Song) Aesthetic(com.afollestad.aesthetic.Aesthetic) Optional(com.annimon.stream.Optional) Priority(com.bumptech.glide.Priority) RequestManager(com.bumptech.glide.RequestManager) HorizontalAlbumView(com.simplecity.amp_library.ui.modelviews.HorizontalAlbumView) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ResourceUtils(com.simplecity.amp_library.utils.ResourceUtils) Schedulers(io.reactivex.schedulers.Schedulers) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) Unbinder(butterknife.Unbinder) ActionBarUtils(com.simplecity.amp_library.utils.ActionBarUtils) LogUtils(com.simplecity.amp_library.utils.LogUtils) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) FloatingActionButton(android.support.design.widget.FloatingActionButton) SortManager(com.simplecity.amp_library.utils.SortManager) ObjectAnimator(android.animation.ObjectAnimator) PopupMenu(android.support.v7.widget.PopupMenu) SubMenu(android.view.SubMenu) ArtworkProvider(com.simplecity.amp_library.model.ArtworkProvider) ViewGroup(android.view.ViewGroup) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) ContextualToolbarHost(com.simplecity.amp_library.ui.views.ContextualToolbarHost) Nullable(android.support.annotation.Nullable) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Album(com.simplecity.amp_library.model.Album) TypefaceManager(com.simplecity.amp_library.utils.TypefaceManager) Stream(com.annimon.stream.Stream) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) ButterKnife(butterknife.ButterKnife) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) DrawerLockManager(com.simplecity.amp_library.ui.drawer.DrawerLockManager) TransitionListenerAdapter(com.simplecity.amp_library.ui.fragments.TransitionListenerAdapter) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) NonNull(android.support.annotation.NonNull) StringUtils(com.simplecity.amp_library.utils.StringUtils) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) AnimationUtils(android.view.animation.AnimationUtils) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) AnimatorSet(android.animation.AnimatorSet) Observable(io.reactivex.Observable) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) PlaceholderProvider(com.simplecity.amp_library.utils.PlaceholderProvider) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) Rx.distinctToMainThread(com.afollestad.aesthetic.Rx.distinctToMainThread) SharedElementCallback(android.support.v4.app.SharedElementCallback) AlwaysCrossFade(com.simplecity.amp_library.glide.utils.AlwaysCrossFade) TaggerDialog(com.simplecity.amp_library.tagger.TaggerDialog) Collectors(com.annimon.stream.Collectors) LayoutInflater(android.view.LayoutInflater) SubheaderView(com.simplecity.amp_library.ui.modelviews.SubheaderView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) AlbumView(com.simplecity.amp_library.ui.modelviews.AlbumView) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) CustomCollapsingToolbarLayout(android.support.design.widget.CustomCollapsingToolbarLayout) Glide(com.bumptech.glide.Glide) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) Toolbar(android.support.v7.widget.Toolbar) Pair(android.support.v4.util.Pair) TransitionInflater(android.transition.TransitionInflater) BaseFragment(com.simplecity.amp_library.ui.fragments.BaseFragment) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) PopupMenu(android.support.v7.widget.PopupMenu)

Example 29 with PopupMenu

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

Example 30 with PopupMenu

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();
}
Also used : SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) MenuItem(android.view.MenuItem) Spannable(android.text.Spannable) 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