Example #1
0
        private void ListView_ItemClick(object sender, int Position)
        {
            if (Position == LocalPlaylists.Count + YoutubePlaylists.Count)
            {
                View        view   = LayoutInflater.Inflate(Resource.Layout.SaveAPlaylist, null);
                AlertDialog dialog = new AlertDialog.Builder(Activity, MainActivity.dialogTheme)
                                     .SetTitle(Resource.String.add_playlist_msg)
                                     .SetView(view)
                                     .SetNegativeButton(Resource.String.cancel, (s, eventArgs) => { })
                                     .SetPositiveButton(Resource.String.add, async(s, eventArgs) =>
                {
                    if (YoutubeExplode.YoutubeClient.TryParsePlaylistId(view.FindViewById <EditText>(Resource.Id.playlistURL).Text, out string playlistID))
                    {
                        PlaylistItem addPlaylist = await PlaylistManager.GetPlaylist(playlistID);
                        PlaylistManager.ForkPlaylist(addPlaylist);

                        if (YoutubePlaylists[YoutubePlaylists.Count - 1].Name == "EMPTY" || YoutubePlaylists[YoutubePlaylists.Count - 1].Name == "Error")
                        {
                            if (YoutubePlaylists[YoutubePlaylists.Count - 1].Name == "EMPTY")
                            {
                                YoutubePlaylists.Insert(YoutubePlaylists.Count - 2, addPlaylist);
                                YoutubePlaylists.RemoveAt(2);
                                adapter.NotifyItemChanged(LocalPlaylists.Count + YoutubePlaylists.Count - 2);
                            }
                            else
                            {
                                YoutubePlaylists.Insert(YoutubePlaylists.Count - 1, addPlaylist);
                                adapter.NotifyItemInserted(LocalPlaylists.Count + YoutubePlaylists.Count - 2);
                            }
                        }
                        else
                        {
                            YoutubePlaylists.Add(addPlaylist);
                            adapter.NotifyItemInserted(LocalPlaylists.Count + YoutubePlaylists.Count - 1);
                        }
                    }
                    else
                    {
                        Snackbar snackBar = Snackbar.Make(MainActivity.instance.FindViewById(Resource.Id.snackBar), MainActivity.instance.GetString(Resource.String.badplaylisturl), Snackbar.LengthLong);
                        snackBar.View.FindViewById <TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
                        snackBar.Show();
                    }
                })
                                     .Show();
                return;
            }

            bool         local    = Position <= LocalPlaylists.Count;
            PlaylistItem playlist = local ?
                                    LocalPlaylists[Position] :
                                    YoutubePlaylists[Position - LocalPlaylists.Count];

            if (playlist.SyncState == SyncState.Error && local)
            {
                //Handle sync errors
            }

            instance = null;
            MainActivity.instance.contentRefresh.Refresh -= OnRefresh;
            MainActivity.instance.contentRefresh.Refresh -= OnRefresh;

            MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, PlaylistTracks.NewInstance(playlist)).AddToBackStack("Playlist Track").Commit();
        }
Example #2
0
        private void ListView_ItemClick(object sender, int position)
        {
            switch (result[position].Kind)
            {
            case YtKind.Video:
                YoutubeManager.Play(result[position].song);
                break;

            case YtKind.Playlist:
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = false;
                MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
                MainActivity.instance.FindViewById <TabLayout>(Resource.Id.tabs).Visibility  = ViewStates.Gone;
                MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, PlaylistTracks.NewInstance(result[position].playlist)).AddToBackStack("Playlist Track").Commit();
                break;

            case YtKind.Channel:
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = false;
                MainActivity.instance.menu.FindItem(Resource.Id.search).CollapseActionView();
                MainActivity.instance.menu.FindItem(Resource.Id.search).ActionView.Focusable = true;
                MainActivity.instance.FindViewById <TabLayout>(Resource.Id.tabs).Visibility  = ViewStates.Gone;
                MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, ChannelDetails.NewInstance(result[position].channel)).AddToBackStack("Channel Details").Commit();
                break;

            default:
                break;
            }
        }