public static void OpenChannelTab(Channel channel) { MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, ChannelDetails.NewInstance(channel)).AddToBackStack("Channel Details").Commit(); }
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { if (items[position].Kind == YtKind.Video) { SongHolder holder = (SongHolder)viewHolder; Song song = items[position].song; holder.Title.Text = song.Title; holder.Artist.Text = song.Artist; holder.reorder.Visibility = ViewStates.Gone; var songAlbumArtUri = Android.Net.Uri.Parse(song.Album); Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder(true)).Into(holder.AlbumArt); holder.more.Tag = position; if (!holder.more.HasOnClickListeners) { holder.more.Click += (sender, e) => { int tagPosition = (int)((ImageView)sender).Tag; MainActivity.instance.More(items[tagPosition].song); }; } if (song.IsLiveStream) { holder.Live.Visibility = ViewStates.Visible; } else { holder.Live.Visibility = ViewStates.Gone; } float scale = MainActivity.instance.Resources.DisplayMetrics.Density; if (position + 1 == items.Count) { holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), listPadding); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters; layoutParams.SetMargins(0, 0, 0, listPadding); holder.more.LayoutParameters = layoutParams; } else { holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f)); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters; layoutParams.SetMargins(0, 0, 0, 0); holder.more.LayoutParameters = layoutParams; } } else if (items[position].Kind == YtKind.Playlist) { PlaylistHolder holder = (PlaylistHolder)viewHolder; PlaylistItem playlist = items[position].playlist; holder.Title.Text = playlist.Name; holder.Owner.Text = playlist.Owner; var songAlbumArtUri = Android.Net.Uri.Parse(playlist.ImageURL); Picasso.With(Android.App.Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder(true)).Into(holder.AlbumArt); holder.more.Tag = position; if (!holder.more.HasOnClickListeners) { holder.more.Click += (sender, e) => { int tagPosition = (int)((ImageView)sender).Tag; YoutubeSearch.instances[0].PlaylistMore(items[tagPosition].playlist); }; } } else if (items[position].Kind == YtKind.Channel) { RecyclerChannelHolder holder = (RecyclerChannelHolder)viewHolder; Channel channel = items[position].channel; holder.Title.Text = channel.Name; Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Transform(new CircleTransformation(false)).Into(holder.AlbumArt); if (!holder.action.HasOnClickListeners) { holder.action.Click += (sender, e) => { YoutubeManager.MixFromChannel(channel.YoutubeID); }; } } else if (items[position].Kind == YtKind.ChannelPreview) { ChannelPreviewHolder holder = (ChannelPreviewHolder)viewHolder; Channel channel = items[position].channel; holder.Name.Text = channel.Name; Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Placeholder(Resource.Color.placeholder).Transform(new CircleTransformation(true)).Into(holder.Logo); DisplayMetrics displayMetrics = new DisplayMetrics(); MainActivity.instance.WindowManager.DefaultDisplay.GetMetrics(displayMetrics); int wholeWidth = (displayMetrics.WidthPixels - MainActivity.instance.DpToPx(15)) / 2; int mixHeight = (int)(wholeWidth * 0.5625); /// width / 16 */ 9 holder.MixOne.LayoutParameters.Height = mixHeight; holder.MixOne.RequestLayout(); holder.MixTwo.LayoutParameters.Height = mixHeight; holder.ChannelLogo.LayoutParameters.Height = mixHeight * 2; Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Placeholder(Resource.Color.placeholder).Fit().CenterCrop().Into(holder.ChannelLogo); List <YtFile> files = items.FindAll(x => x.Kind == YtKind.Video && x.song.Artist == channel.Name); if (files.Count > 0) { Picasso.With(Android.App.Application.Context).Load(files[0].song.Album).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder()).Into(holder.MixOne); } if (files.Count > 1) { Picasso.With(Android.App.Application.Context).Load(files[1].song.Album).Placeholder(Resource.Color.placeholder).Transform(new RemoveBlackBorder()).Into(holder.MixTwo); } if (!holder.ChannelHolder.HasOnClickListeners) { holder.ChannelHolder.Click += (sender, e) => { 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(Resource.Id.tabs).Visibility = ViewStates.Gone; MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, ChannelDetails.NewInstance(channel)).AddToBackStack("Channel Details").Commit(); }; } if (!holder.MixHolder.HasOnClickListeners) { holder.MixHolder.Click += (sender, e) => { YoutubeManager.MixFromChannel(channel.YoutubeID); }; } } }
void OnClick(int position) { if (UseChannel) { MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, ChannelDetails.NewInstance(channels[position])).AddToBackStack("Channel Details").Commit(); } else { MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, PlaylistTracks.NewInstance(playlists[position])).AddToBackStack("Playlist Track").Commit(); } }