use of com.andrew.apollo.model.Genre in project frostwire by frostwire.
the class ApolloFragment method onCreateContextMenu.
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
// Get the position of the selected item
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
int mSelectedPosition = info.position - mAdapter.getOffset();
// Create a new song
mItem = mAdapter.getItem(mSelectedPosition);
// TODO: Remove these mutable properties, parametrize the onMenuEvent handlers.
if (mItem instanceof Song) {
Song mSong = (Song) mItem;
mSelectedId = mSong.mSongId;
mSongName = mSong.mSongName;
mAlbumName = mSong.mAlbumName;
mArtistName = mSong.mArtistName;
mSongList = null;
} else if (mItem instanceof Album) {
Album mAlbum = (Album) mItem;
mSelectedId = mAlbum.mAlbumId;
mSongName = null;
mAlbumName = mAlbum.mAlbumName;
mArtistName = mAlbum.mArtistName;
mSongList = MusicUtils.getSongListForAlbum(getActivity(), mAlbum.mAlbumId);
} else if (mItem instanceof Artist) {
Artist mArtist = (Artist) mItem;
mSelectedId = mArtist.mArtistId;
mSongName = null;
mArtistName = mArtist.mArtistName;
mSongList = MusicUtils.getSongListForArtist(getActivity(), mArtist.mArtistId);
} else if (mItem instanceof Genre) {
Genre mGenre = (Genre) mItem;
mSelectedId = mGenre.mGenreId;
mSongList = MusicUtils.getSongListForGenre(getActivity(), mGenre.mGenreId);
} else if (mItem instanceof Playlist) {
Playlist mPlaylist = (Playlist) mItem;
mSelectedId = mPlaylist.mPlaylistId;
if (mSelectedId == PlaylistLoader.FAVORITE_PLAYLIST_ID) {
mSongList = MusicUtils.getSongListForFavorites(getActivity());
} else if (mSelectedId == PlaylistLoader.LAST_ADDED_PLAYLIST_ID) {
mSongList = MusicUtils.getSongListForLastAdded(getActivity());
} else {
mSongList = MusicUtils.getSongListForPlaylist(getActivity(), mPlaylist.mPlaylistId);
}
}
// Play the selected songs
menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection)).setIcon(R.drawable.contextmenu_icon_play);
// Play the next song
menu.add(GROUP_ID, FragmentMenuItems.PLAY_NEXT, Menu.NONE, getString(R.string.context_menu_play_next)).setIcon(R.drawable.contextmenu_icon_next);
// Add the song/album to the queue
menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_QUEUE, Menu.NONE, getString(R.string.add_to_queue)).setIcon(R.drawable.contextmenu_icon_queue_add);
// Add the song to favorite's playlist
menu.add(GROUP_ID, FragmentMenuItems.ADD_TO_FAVORITES, Menu.NONE, R.string.add_to_favorites).setIcon(R.drawable.contextmenu_icon_favorite);
// Add the song/album to a playlist
final SubMenu subMenu = menu.addSubMenu(GROUP_ID, FragmentMenuItems.ADD_TO_PLAYLIST, Menu.NONE, R.string.add_to_playlist).setIcon(R.drawable.contextmenu_icon_add_to_existing_playlist_dark);
MusicUtils.makePlaylistMenu(getActivity(), GROUP_ID, subMenu, true);
if (mItem instanceof Song) {
menu.add(GROUP_ID, FragmentMenuItems.USE_AS_RINGTONE, Menu.NONE, getString(R.string.context_menu_use_as_ringtone)).setIcon(R.drawable.contextmenu_icon_ringtone);
}
// More by artist
menu.add(GROUP_ID, FragmentMenuItems.MORE_BY_ARTIST, Menu.NONE, getString(R.string.context_menu_more_by_artist)).setIcon(R.drawable.contextmenu_icon_artist);
// Delete the album
menu.add(GROUP_ID, FragmentMenuItems.DELETE, Menu.NONE, getString(R.string.context_menu_delete)).setIcon(R.drawable.contextmenu_icon_trash);
}
Aggregations