private void OnPopupMenuClick(object sender, EventArgs e, int pos) { var menu = new Android.Widget.PopupMenu(_context, (View)sender); menu.MenuItemClick += (s, args) => { switch (args.Item.ItemId) { case Resource.Id.popup_song_play: { MusicPlayer.PlayAll(_context, GetSongIds(), pos, -1, MusicUtils.SourceTypeId.NA, false); break; } case Resource.Id.popup_song_goto_album: { NavigationUtils.GoToAlbum(_context, _songs[pos].AlbumId); break; } case Resource.Id.popup_song_goto_artist: { NavigationUtils.GoToArtist(_context, _songs[pos].ArtistId); break; } case Resource.Id.popup_song_addto_playlist: { // TODO: Create add to dialog AddPlaylistDialog.GetInstance(_songs[pos]).Show(((AppCompatActivity)_context).SupportFragmentManager, "Add to playlist"); // not finish break; } case Resource.Id.popup_song_delete: { MusicUtils.ShowDeleteSongDialog(_context, new long[] { _songs[pos].Id }); break; } } }; }
// Onclick Pop Up menu public void OnClick(View v, int pos) { var menu = new PopupMenu(_context, v); menu.MenuItemClick += (s, arg) => { switch (arg.Item.ItemId) { case Resource.Id.popup_song_remove_playlist: { MusicUtils.RemoveFromPlaylist(_context, _songs[pos].Id, _playlistId); _songs.RemoveAt(pos); NotifyItemRemoved(pos); break; } case Resource.Id.popup_song_play: { MusicPlayer.PlayAll(_context, _songIds, pos, -1, MusicUtils.SourceTypeId.NA, false); break; } case Resource.Id.popup_song_play_next: { MusicPlayer.PlayNext(_context, new long[] { _songs[pos].Id }, -1, MusicUtils.SourceTypeId.NA); break; } case Resource.Id.popup_song_goto_album: { NavigationUtils.GoToAlbum(_context, _songs[pos].AlbumId); break; } case Resource.Id.popup_song_goto_artist: { NavigationUtils.GoToArtist(_context, _songs[pos].ArtistId); break; } case Resource.Id.popup_song_addto_queue: { MusicPlayer.AddToQueue(_context, new long[] { _songs[pos].Id }, -1, MusicUtils.SourceTypeId.NA); break; } case Resource.Id.popup_song_addto_playlist: { // TODO: Create add to dialog AddPlaylistDialog.GetInstance(_songs[pos]).Show(_context.SupportFragmentManager, "Add to playlist"); // not finish break; } case Resource.Id.popup_song_share: { MusicUtils.ShareSong(_context, _songs[pos].Id); break; } case Resource.Id.popup_song_delete: { MusicUtils.ShowDeleteSongDialog(_context, new long[] { _songs[pos].Id }); break; } default: break; } }; menu.Inflate(Resource.Menu.popup_song); menu.Show(); if (_isPlaylist) { menu.Menu.FindItem(Resource.Id.popup_song_remove_playlist).SetVisible(true); } }