Exemplo n.º 1
0
        private async void More(object s, EventArgs e)
        {
            Song item = await MusicPlayer.GetItem();

            BottomSheetDialog bottomSheet = new BottomSheetDialog(MainActivity.instance);
            View bottomView = MainActivity.instance.LayoutInflater.Inflate(Resource.Layout.BottomSheet, null);

            bottomView.FindViewById <TextView>(Resource.Id.bsTitle).Text  = item.Title;
            bottomView.FindViewById <TextView>(Resource.Id.bsArtist).Text = item.Artist;
            if (item.AlbumArt == -1 || item.IsYt)
            {
                Picasso.With(MainActivity.instance).Load(item.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(bottomView.FindViewById <ImageView>(Resource.Id.bsArt));
            }
            else
            {
                var songCover       = Android.Net.Uri.Parse("content://media/external/audio/albumart");
                var songAlbumArtUri = ContentUris.WithAppendedId(songCover, item.AlbumArt);

                Picasso.With(MainActivity.instance).Load(songAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(bottomView.FindViewById <ImageView>(Resource.Id.bsArt));
            }
            bottomSheet.SetContentView(bottomView);

            List <BottomSheetAction> actions = new List <BottomSheetAction>
            {
                new BottomSheetAction(Resource.Drawable.Timer, Resources.GetString(Resource.String.timer), (sender, eventArg) => { SleepDialog(); bottomSheet.Dismiss(); }),
                new BottomSheetAction(Resource.Drawable.PlaylistAdd, Resources.GetString(Resource.String.add_to_playlist), (sender, eventArg) => { PlaylistManager.AddSongToPlaylistDialog(item); bottomSheet.Dismiss(); })
            };

            if (item.IsYt)
            {
                actions.AddRange(new BottomSheetAction[]
                {
                    new BottomSheetAction(Resource.Drawable.PlayCircle, Resources.GetString(Resource.String.create_mix_from_song), (sender, eventArg) =>
                    {
                        YoutubeManager.CreateMixFromSong(item);
                        bottomSheet.Dismiss();
                    }),
                    new BottomSheetAction(Resource.Drawable.Download, Resources.GetString(Resource.String.download), (sender, eventArg) =>
                    {
                        Console.WriteLine("&Trying to download " + item.Title);
                        YoutubeManager.Download(new[] { item });
                        bottomSheet.Dismiss();
                    }),
                    new BottomSheetAction(Resource.Drawable.OpenInBrowser, Resources.GetString(Resource.String.open_youtube), (sender, eventArg) =>
                    {
                        Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("vnd.youtube://" + MusicPlayer.queue[MusicPlayer.CurrentID()].YoutubeID));
                        StartActivity(intent);
                        bottomSheet.Dismiss();
                    })
                });

                if (item.ChannelID != null && item.ChannelID != "")
                {
                    actions.Add(new BottomSheetAction(Resource.Drawable.account, Resources.GetString(Resource.String.goto_channel), (sender, eventArg) =>
                    {
                        ChannelManager.OpenChannelTab(item.ChannelID);
                        bottomSheet.Dismiss();
                    }));
                }
            }
            else
            {
                actions.Add(new BottomSheetAction(Resource.Drawable.Edit, Resources.GetString(Resource.String.edit_metadata), (sender, eventArg) =>
                {
                    LocalManager.EditMetadata(item, MusicPlayer.CurrentID());
                    bottomSheet.Dismiss();
                }));
            }

            bottomSheet.FindViewById <ListView>(Resource.Id.bsItems).Adapter = new BottomSheetAdapter(MainActivity.instance, Resource.Layout.BottomSheetText, actions);
            bottomSheet.Show();
        }