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());
}
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();
}
});
}
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();
}
});
}
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);
}
});
}
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();
}
});
}
Aggregations