Search in sources :

Example 21 with PopupMenu

use of android.widget.PopupMenu in project materialistic by hidroh.

the class BaseListActivityLandTest method testSelectItemOpenStory.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testSelectItemOpenStory() {
    assertThat(activity.findViewById(R.id.empty_selection)).isVisible();
    activity.onItemSelected(new TestHnItem(1L) {

        @NonNull
        @Override
        public String getType() {
            return STORY_TYPE;
        }

        @Override
        public String getUrl() {
            return "http://example.com";
        }
    });
    assertThat(activity.findViewById(R.id.empty_selection)).isNotVisible();
    assertStoryMode();
    shadowOf(activity).clickMenuItem(R.id.menu_share);
    PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
    assertNotNull(popupMenu);
    assertThat(popupMenu.getMenu()).hasItem(R.id.menu_article).hasItem(R.id.menu_comments);
    shadowOf(activity).clickMenuItem(R.id.menu_external);
    assertNotNull(ShadowPopupMenu.getLatestPopupMenu());
}
Also used : NonNull(android.support.annotation.NonNull) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) PopupMenu(android.widget.PopupMenu) ShadowPopupMenu(org.robolectric.shadows.ShadowPopupMenu) Test(org.junit.Test) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) TargetApi(android.annotation.TargetApi)

Example 22 with PopupMenu

use of android.widget.PopupMenu in project Timber by naman14.

the class AlbumSongsAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(ItemHolder itemHolder, final int position) {
    itemHolder.menu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.popup_song_play:
                            MusicPlayer.playAll(mContext, songIDs, position, -1, TimberUtils.IdType.NA, false);
                            break;
                        case R.id.popup_song_play_next:
                            long[] ids = new long[1];
                            ids[0] = arraylist.get(position).id;
                            MusicPlayer.playNext(mContext, ids, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_goto_album:
                            NavigationUtils.goToAlbum(mContext, arraylist.get(position).albumId);
                            break;
                        case R.id.popup_song_goto_artist:
                            NavigationUtils.goToArtist(mContext, arraylist.get(position).artistId);
                            break;
                        case R.id.popup_song_addto_queue:
                            long[] id = new long[1];
                            id[0] = arraylist.get(position).id;
                            MusicPlayer.addToQueue(mContext, id, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_addto_playlist:
                            AddPlaylistDialog.newInstance(arraylist.get(position)).show(((AppCompatActivity) mContext).getSupportFragmentManager(), "ADD_PLAYLIST");
                            break;
                        case R.id.popup_song_share:
                            TimberUtils.shareTrack(mContext, arraylist.get(position).id);
                            break;
                        case R.id.popup_song_delete:
                            long[] deleteIds = { arraylist.get(position).id };
                            TimberUtils.showDeleteDialog(mContext, arraylist.get(position).title, deleteIds, AlbumSongsAdapter.this, position);
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_song);
            menu.show();
        }
    });
}
Also used : MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) PopupMenu(android.widget.PopupMenu)

Example 23 with PopupMenu

use of android.widget.PopupMenu in project Timber by naman14.

the class SearchAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(ItemHolder itemHolder, final int position) {
    itemHolder.menu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    long[] song = new long[1];
                    song[0] = ((Song) searchResults.get(position)).id;
                    switch(item.getItemId()) {
                        case R.id.popup_song_play:
                            MusicPlayer.playAll(mContext, song, 0, -1, TimberUtils.IdType.NA, false);
                            break;
                        case R.id.popup_song_play_next:
                            MusicPlayer.playNext(mContext, song, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_goto_album:
                            NavigationUtils.navigateToAlbum(mContext, ((Song) searchResults.get(position)).albumId, null);
                            break;
                        case R.id.popup_song_goto_artist:
                            NavigationUtils.navigateToArtist(mContext, ((Song) searchResults.get(position)).artistId, null);
                            break;
                        case R.id.popup_song_addto_queue:
                            MusicPlayer.addToQueue(mContext, song, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_addto_playlist:
                            AddPlaylistDialog.newInstance(((Song) searchResults.get(position))).show(((AppCompatActivity) mContext).getSupportFragmentManager(), "ADD_PLAYLIST");
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_song);
            menu.show();
        }
    });
}
Also used : MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) PopupMenu(android.widget.PopupMenu)

Example 24 with PopupMenu

use of android.widget.PopupMenu in project Timber by naman14.

the class SongsListAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(ItemHolder itemHolder, final int position) {
    itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.popup_song_remove_playlist:
                            TimberUtils.removeFromPlaylist(mContext, arraylist.get(position).id, playlistId);
                            removeSongAt(position);
                            notifyItemRemoved(position);
                            break;
                        case R.id.popup_song_play:
                            MusicPlayer.playAll(mContext, songIDs, position, -1, TimberUtils.IdType.NA, false);
                            break;
                        case R.id.popup_song_play_next:
                            long[] ids = new long[1];
                            ids[0] = arraylist.get(position).id;
                            MusicPlayer.playNext(mContext, ids, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_goto_album:
                            NavigationUtils.goToAlbum(mContext, arraylist.get(position).albumId);
                            break;
                        case R.id.popup_song_goto_artist:
                            NavigationUtils.goToArtist(mContext, arraylist.get(position).artistId);
                            break;
                        case R.id.popup_song_addto_queue:
                            long[] id = new long[1];
                            id[0] = arraylist.get(position).id;
                            MusicPlayer.addToQueue(mContext, id, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_addto_playlist:
                            AddPlaylistDialog.newInstance(arraylist.get(position)).show(mContext.getSupportFragmentManager(), "ADD_PLAYLIST");
                            break;
                        case R.id.popup_song_share:
                            TimberUtils.shareTrack(mContext, arraylist.get(position).id);
                            break;
                        case R.id.popup_song_delete:
                            long[] deleteIds = { arraylist.get(position).id };
                            TimberUtils.showDeleteDialog(mContext, arraylist.get(position).title, deleteIds, SongsListAdapter.this, position);
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_song);
            menu.show();
            if (isPlaylist)
                menu.getMenu().findItem(R.id.popup_song_remove_playlist).setVisible(true);
        }
    });
}
Also used : MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) PopupMenu(android.widget.PopupMenu)

Example 25 with PopupMenu

use of android.widget.PopupMenu in project Timber by naman14.

the class BaseQueueAdapter method setOnPopupMenuListener.

private void setOnPopupMenuListener(ItemHolder itemHolder, final int position) {
    itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.popup_song_play:
                            MusicPlayer.playAll(mContext, getSongIds(), position, -1, TimberUtils.IdType.NA, false);
                            break;
                        case R.id.popup_song_play_next:
                            long[] ids = new long[1];
                            ids[0] = arraylist.get(position).id;
                            MusicPlayer.playNext(mContext, ids, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_goto_album:
                            NavigationUtils.goToAlbum(mContext, arraylist.get(position).albumId);
                            break;
                        case R.id.popup_song_goto_artist:
                            NavigationUtils.goToArtist(mContext, arraylist.get(position).artistId);
                            break;
                        case R.id.popup_song_addto_queue:
                            long[] id = new long[1];
                            id[0] = arraylist.get(position).id;
                            MusicPlayer.addToQueue(mContext, id, -1, TimberUtils.IdType.NA);
                            break;
                        case R.id.popup_song_addto_playlist:
                            AddPlaylistDialog.newInstance(arraylist.get(position)).show(mContext.getSupportFragmentManager(), "ADD_PLAYLIST");
                            break;
                        case R.id.popup_song_share:
                            TimberUtils.shareTrack(mContext, arraylist.get(position).id);
                            break;
                        case R.id.popup_song_delete:
                            long[] deleteIds = { arraylist.get(position).id };
                            TimberUtils.showDeleteDialog(mContext, arraylist.get(position).title, deleteIds, BaseQueueAdapter.this, position);
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_song);
            menu.show();
        }
    });
}
Also used : MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) PopupMenu(android.widget.PopupMenu)

Aggregations

PopupMenu (android.widget.PopupMenu)88 MenuItem (android.view.MenuItem)52 View (android.view.View)38 TextView (android.widget.TextView)35 ImageView (android.widget.ImageView)29 RecyclerView (android.support.v7.widget.RecyclerView)21 TargetApi (android.annotation.TargetApi)20 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)19 Test (org.junit.Test)19 ShadowPopupMenu (org.robolectric.shadows.ShadowPopupMenu)19 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)18 Context (android.content.Context)12 DialogAction (com.afollestad.materialdialogs.DialogAction)12 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)12 Intent (android.content.Intent)11 NonNull (android.support.annotation.NonNull)8 Menu (android.view.Menu)7 AdapterView (android.widget.AdapterView)6 ListView (android.widget.ListView)6 Song (io.hefuyi.listener.mvp.model.Song)6