Making channel header height precalculated, adding select feedback and adding header click to go to the channel tab.

This commit is contained in:
Anonymus Raccoon
2019-06-26 17:01:32 +02:00
parent 08587a066a
commit 8721e7c731
3 changed files with 35 additions and 10 deletions

View File

@@ -261,7 +261,7 @@ namespace Opus.Api
} }
/// <summary> /// <summary>
/// This method will remove playback calls and get requests from the /// This method will remove playback calls
/// </summary> /// </summary>
private void Cancel() private void Cancel()
{ {

View File

@@ -1,5 +1,6 @@
using Android.Graphics; using Android.Graphics;
using Android.Support.V7.Widget; using Android.Support.V7.Widget;
using Android.Util;
using Android.Views; using Android.Views;
using Android.Widget; using Android.Widget;
using Opus.Api; using Opus.Api;
@@ -15,7 +16,7 @@ namespace Opus.Adapter
public class YtAdapter : RecyclerView.Adapter public class YtAdapter : RecyclerView.Adapter
{ {
public int listPadding; public int listPadding;
private List<YtFile> items; private readonly List<YtFile> items;
public event EventHandler<int> ItemClick; public event EventHandler<int> ItemClick;
public event EventHandler<int> ItemLongCLick; public event EventHandler<int> ItemLongCLick;
@@ -116,16 +117,35 @@ namespace Opus.Adapter
holder.Name.Text = channel.Name; 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); Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Placeholder(Resource.Color.placeholder).Transform(new CircleTransformation(true)).Into(holder.Logo);
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).Transform(new RemoveBlackBorder()).Into(holder.MixOne);
if (files.Count > 1)
Picasso.With(Android.App.Application.Context).Load(files[1].song.Album).Transform(new RemoveBlackBorder()).Into(holder.MixTwo);
holder.MixOne.ViewTreeObserver.Draw += (sender, e) => 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)
{ {
Picasso.With(Android.App.Application.Context).Load(channel.ImageURL).Placeholder(Resource.Color.placeholder).Fit().CenterCrop().Into(holder.ChannelLogo); 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) if (!holder.MixHolder.HasOnClickListeners)
{ {

View File

@@ -11,6 +11,7 @@
android:background="#141414" android:background="#141414"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:id="@+id/channelHolder" > android:id="@+id/channelHolder" >
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -37,11 +38,13 @@
android:orientation="horizontal" android:orientation="horizontal"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:id="@+id/mixHolder" > android:id="@+id/mixHolder" >
<ImageView <ImageView
android:layout_width="0px" android:layout_width="0px"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@color/placeholder"
android:id="@+id/channelLogo" /> android:id="@+id/channelLogo" />
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
@@ -52,12 +55,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="1" android:layout_weight="1"
android:src="@color/placeholder"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:id="@+id/mixOne" /> android:id="@+id/mixOne" />
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="1" android:layout_weight="1"
android:src="@color/placeholder"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:id="@+id/mixTwo" /> android:id="@+id/mixTwo" />
</LinearLayout> </LinearLayout>