|
|
@ -13,6 +13,7 @@ namespace QuickPlay
|
|
|
|
{
|
|
|
|
{
|
|
|
|
class SongRecyclerAdapter : Android.Support.V7.Widget.RecyclerView.Adapter
|
|
|
|
class SongRecyclerAdapter : Android.Support.V7.Widget.RecyclerView.Adapter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
public event EventHandler<IPlayable> SongClick;
|
|
|
|
IPlayer player;
|
|
|
|
IPlayer player;
|
|
|
|
ILayoutStrategy layoutStrategy;
|
|
|
|
ILayoutStrategy layoutStrategy;
|
|
|
|
public SongRecyclerAdapter(IPlayer player, ILayoutStrategy layoutStrategy)
|
|
|
|
public SongRecyclerAdapter(IPlayer player, ILayoutStrategy layoutStrategy)
|
|
|
@ -31,7 +32,7 @@ namespace QuickPlay
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// I admit I have little idea what I am doing.
|
|
|
|
// I admit I have little idea what I am doing.
|
|
|
|
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.songLayout, parent, false);
|
|
|
|
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.songLayout, parent, false);
|
|
|
|
return new SongRecyclerViewHolder(itemView);
|
|
|
|
return new SongRecyclerViewHolder(itemView, OnItemClick);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
|
|
|
|
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -39,13 +40,19 @@ namespace QuickPlay
|
|
|
|
List<IPlayable> layout = layoutStrategy.LayOut(player.Songs.Values);
|
|
|
|
List<IPlayable> layout = layoutStrategy.LayOut(player.Songs.Values);
|
|
|
|
vh.SongName.Text = layout[position].Identifier;
|
|
|
|
vh.SongName.Text = layout[position].Identifier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnItemClick(int position)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IPlayable playable = layoutStrategy.LayOut(player.Songs.Values)[position];
|
|
|
|
|
|
|
|
if (SongClick != null) SongClick.Invoke(this, playable);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class SongRecyclerViewHolder : Android.Support.V7.Widget.RecyclerView.ViewHolder
|
|
|
|
class SongRecyclerViewHolder : Android.Support.V7.Widget.RecyclerView.ViewHolder
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public TextView SongName { get; private set; }
|
|
|
|
public TextView SongName { get; private set; }
|
|
|
|
public SongRecyclerViewHolder(View itemView) : base(itemView)
|
|
|
|
public SongRecyclerViewHolder(View itemView, Action<int> callback) : base(itemView)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SongName = itemView.FindViewById<TextView>(Resource.Id.songName);
|
|
|
|
SongName = itemView.FindViewById<TextView>(Resource.Id.songName);
|
|
|
|
|
|
|
|
itemView.Click += (sender, e) => callback(base.LayoutPosition);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|