mirror of
https://github.com/zoriya/Opus.git
synced 2026-06-03 06:25:31 +00:00
Reworking home screen
This commit is contained in:
@@ -578,6 +578,28 @@ namespace MusicApp
|
||||
YoutubeEngine.instances = null;
|
||||
}
|
||||
|
||||
if(PlaylistTracks.instance != null)
|
||||
{
|
||||
HideSearch();
|
||||
if (PlaylistTracks.instance.isEmpty)
|
||||
{
|
||||
ViewGroup rootView = FindViewById<ViewGroup>(Android.Resource.Id.Content);
|
||||
rootView.RemoveView(PlaylistTracks.instance.emptyView);
|
||||
}
|
||||
SupportActionBar.SetHomeButtonEnabled(false);
|
||||
SupportActionBar.SetDisplayHomeAsUpEnabled(false);
|
||||
SupportActionBar.SetDisplayShowTitleEnabled(true);
|
||||
SupportActionBar.Title = "MusicApp";
|
||||
|
||||
contentRefresh.Refresh -= PlaylistTracks.instance.OnRefresh;
|
||||
OnPaddingChanged -= PlaylistTracks.instance.OnPaddingChanged;
|
||||
FindViewById<AppBarLayout>(Resource.Id.appbar).RemoveOnOffsetChangedListener(PlaylistTracks.instance);
|
||||
FindViewById<RelativeLayout>(Resource.Id.playlistHeader).Visibility = ViewStates.Gone;
|
||||
|
||||
SupportFragmentManager.PopBackStack();
|
||||
PlaylistTracks.instance = null;
|
||||
}
|
||||
|
||||
Android.Support.V4.App.Fragment fragment = null;
|
||||
switch (layout)
|
||||
{
|
||||
@@ -822,7 +844,6 @@ namespace MusicApp
|
||||
{
|
||||
if (adapter.Count == 2)
|
||||
{
|
||||
Console.WriteLine("&Removing browse instance");
|
||||
Browse.instance = null;
|
||||
FolderBrowse.instance = null;
|
||||
}
|
||||
|
||||
@@ -257,6 +257,8 @@
|
||||
<Compile Include="Resources\Portable Class\HomeHolder.cs" />
|
||||
<Compile Include="Resources\Portable Class\HomeMultipleSong.cs" />
|
||||
<Compile Include="Resources\Portable Class\ItemTouchCallback.cs" />
|
||||
<Compile Include="Resources\Portable Class\LineAdapter.cs" />
|
||||
<Compile Include="Resources\Portable Class\LineSongHolder.cs" />
|
||||
<Compile Include="Resources\Portable Class\MusicPlayer.cs" />
|
||||
<Compile Include="Resources\Portable Class\PagerFragment.cs" />
|
||||
<Compile Include="Resources\Portable Class\PercentTransform.cs" />
|
||||
@@ -620,6 +622,12 @@
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\menu\ytplaylistnowrite_header_more.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\LineSongs.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\LineSong.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets')" />
|
||||
<Import Project="..\packages\Xamarin.Android.Support.v7.Preference.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.v7.Preference.targets" Condition="Exists('..\packages\Xamarin.Android.Support.v7.Preference.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.v7.Preference.targets')" />
|
||||
|
||||
@@ -61,205 +61,219 @@ namespace MusicApp.Resources.Portable_Class
|
||||
return view;
|
||||
}
|
||||
|
||||
private async void PopulateSongs()
|
||||
private /*async*/ void PopulateSongs()
|
||||
{
|
||||
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Activity);
|
||||
string[] selectedTopicsID = prefManager.GetStringSet("selectedTopicsID", new string[] { }).ToArray();
|
||||
HomeSection queue = new HomeSection("Queue", SectionType.SinglePlaylist, MusicPlayer.queue);
|
||||
if(queue.contentValue.Count > 0)
|
||||
adapterItems.Add(queue);
|
||||
|
||||
if (selectedTopicsID.Length < 1)
|
||||
return;
|
||||
Console.WriteLine("&Queue nb: " + MusicPlayer.queue.Count);
|
||||
|
||||
if (YoutubeEngine.youtubeService == null)
|
||||
MainActivity.instance.Login();
|
||||
adapter = new HomeAdapter(adapterItems);
|
||||
ListView.SetAdapter(adapter);
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
|
||||
await MainActivity.instance.WaitForYoutube();
|
||||
#region yt
|
||||
//ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Activity);
|
||||
//string[] selectedTopicsID = prefManager.GetStringSet("selectedTopicsID", new string[] { }).ToArray();
|
||||
|
||||
List<HomeItem> Items = new List<HomeItem>();
|
||||
//if (selectedTopicsID.Length < 1)
|
||||
// return;
|
||||
|
||||
foreach (string topic in selectedTopicsID)
|
||||
{
|
||||
YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
//if (YoutubeEngine.youtubeService == null)
|
||||
// MainActivity.instance.Login();
|
||||
|
||||
ChannelSectionsResource.ListRequest request = youtube.ChannelSections.List("snippet, contentDetails");
|
||||
request.ChannelId = topic;
|
||||
//await MainActivity.instance.WaitForYoutube();
|
||||
|
||||
ChannelSectionListResponse response = await request.ExecuteAsync();
|
||||
//List<HomeItem> Items = new List<HomeItem>();
|
||||
|
||||
foreach (var section in response.Items)
|
||||
{
|
||||
if (section.Snippet.Type == "channelsectionTypeUndefined")
|
||||
continue;
|
||||
//foreach (string topic in selectedTopicsID)
|
||||
//{
|
||||
// YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
|
||||
SectionType type = SectionType.None;
|
||||
List<string> contentValue = null;
|
||||
switch (section.Snippet.Type)
|
||||
{
|
||||
case "multipleChannels":
|
||||
type = SectionType.ChannelList;
|
||||
contentValue = section.ContentDetails.Channels.ToList();
|
||||
break;
|
||||
case "multiplePlaylists":
|
||||
contentValue = section.ContentDetails.Playlists.ToList();
|
||||
type = SectionType.PlaylistList;
|
||||
break;
|
||||
case "singlePlaylist":
|
||||
contentValue = section.ContentDetails.Playlists.ToList();
|
||||
type = SectionType.SinglePlaylist;
|
||||
break;
|
||||
default:
|
||||
contentValue = new List<string>();
|
||||
break;
|
||||
}
|
||||
// ChannelSectionsResource.ListRequest request = youtube.ChannelSections.List("snippet, contentDetails");
|
||||
// request.ChannelId = topic;
|
||||
|
||||
HomeItem item = new HomeItem(section.Snippet.Title, type, contentValue);
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
// ChannelSectionListResponse response = await request.ExecuteAsync();
|
||||
|
||||
List<HomeItem> itemsSave = Items;
|
||||
foreach(HomeItem item in Items)
|
||||
{
|
||||
List<Song> contentValue = new List<Song>
|
||||
{
|
||||
new Song("HeaderSlot", null, null, null, -1, -1, null)
|
||||
};
|
||||
// foreach (var section in response.Items)
|
||||
// {
|
||||
// if (section.Snippet.Type == "channelsectionTypeUndefined")
|
||||
// continue;
|
||||
|
||||
switch (item.contentType)
|
||||
{
|
||||
case SectionType.ChannelList:
|
||||
if(adapterItems.Where(x => x.SectionTitle == item.SectionTitle).Count() == 0)
|
||||
{
|
||||
foreach (string channelID in item.contentValue)
|
||||
{
|
||||
YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
// SectionType type = SectionType.None;
|
||||
// List<string> contentValue = null;
|
||||
// switch (section.Snippet.Type)
|
||||
// {
|
||||
// case "multipleChannels":
|
||||
// type = SectionType.ChannelList;
|
||||
// contentValue = section.ContentDetails.Channels.ToList();
|
||||
// break;
|
||||
// case "multiplePlaylists":
|
||||
// contentValue = section.ContentDetails.Playlists.ToList();
|
||||
// type = SectionType.PlaylistList;
|
||||
// break;
|
||||
// case "singlePlaylist":
|
||||
// contentValue = section.ContentDetails.Playlists.ToList();
|
||||
// type = SectionType.SinglePlaylist;
|
||||
// break;
|
||||
// default:
|
||||
// contentValue = new List<string>();
|
||||
// break;
|
||||
// }
|
||||
|
||||
ChannelsResource.ListRequest request = youtube.Channels.List("snippet");
|
||||
request.Id = channelID;
|
||||
// HomeItem item = new HomeItem(section.Snippet.Title, type, contentValue);
|
||||
// Items.Add(item);
|
||||
// }
|
||||
//}
|
||||
|
||||
ChannelListResponse response = await request.ExecuteAsync();
|
||||
//List<HomeItem> itemsSave = Items;
|
||||
//foreach(HomeItem item in Items)
|
||||
//{
|
||||
// List<Song> contentValue = new List<Song>
|
||||
// {
|
||||
// new Song("HeaderSlot", null, null, null, -1, -1, null)
|
||||
// };
|
||||
|
||||
foreach (var ytItem in response.Items)
|
||||
{
|
||||
Song channel = new Song(ytItem.Snippet.Title, "", ytItem.Snippet.Thumbnails.Default__.Url, ytItem.Id, -1, -1, null, true);
|
||||
contentValue.Add(channel);
|
||||
// switch (item.contentType)
|
||||
// {
|
||||
// case SectionType.ChannelList:
|
||||
// if(adapterItems.Where(x => x.SectionTitle == item.SectionTitle).Count() == 0)
|
||||
// {
|
||||
// foreach (string channelID in item.contentValue)
|
||||
// {
|
||||
// YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
|
||||
if (instance == null)
|
||||
return;
|
||||
}
|
||||
// ChannelsResource.ListRequest request = youtube.Channels.List("snippet");
|
||||
// request.Id = channelID;
|
||||
|
||||
}
|
||||
// ChannelListResponse response = await request.ExecuteAsync();
|
||||
|
||||
HomeSection section = new HomeSection(item.SectionTitle, item.contentType, contentValue);
|
||||
// foreach (var ytItem in response.Items)
|
||||
// {
|
||||
// Song channel = new Song(ytItem.Snippet.Title, "", ytItem.Snippet.Thumbnails.Default__.Url, ytItem.Id, -1, -1, null, true);
|
||||
// contentValue.Add(channel);
|
||||
|
||||
if (adapter == null)
|
||||
{
|
||||
adapterItems.Add(section);
|
||||
adapter = new HomeAdapter(adapterItems);
|
||||
ListView.SetAdapter(adapter);
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
adapter.ItemLongClick += ListView_ItemLongCLick;
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
}
|
||||
else
|
||||
{
|
||||
adapterItems.Add(section);
|
||||
adapter.AddToList(new List<HomeSection>() { section });
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SectionType.SinglePlaylist:
|
||||
if (adapterItems.Where(x => x.SectionTitle == item.SectionTitle).Count() == 0)
|
||||
{
|
||||
YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
// if (instance == null)
|
||||
// return;
|
||||
// }
|
||||
|
||||
PlaylistItemsResource.ListRequest request = youtube.PlaylistItems.List("snippet, contentDetails");
|
||||
request.PlaylistId = item.contentValue[0];
|
||||
request.MaxResults = 10;
|
||||
request.PageToken = "";
|
||||
// }
|
||||
|
||||
PlaylistItemListResponse response = await request.ExecuteAsync();
|
||||
// HomeSection section = new HomeSection(item.SectionTitle, item.contentType, contentValue);
|
||||
|
||||
foreach (var ytItem in response.Items)
|
||||
{
|
||||
Song song = new Song(ytItem.Snippet.Title, ytItem.Snippet.ChannelTitle, ytItem.Snippet.Thumbnails.High.Url, ytItem.ContentDetails.VideoId, -1, -1, ytItem.ContentDetails.VideoId, true);
|
||||
contentValue.Add(song);
|
||||
// if (adapter == null)
|
||||
// {
|
||||
// adapterItems.Add(section);
|
||||
// adapter = new HomeAdapter(adapterItems);
|
||||
// ListView.SetAdapter(adapter);
|
||||
// adapter.ItemClick += ListView_ItemClick;
|
||||
// adapter.ItemLongClick += ListView_ItemLongCLick;
|
||||
// ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
// ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// adapterItems.Add(section);
|
||||
// adapter.AddToList(new List<HomeSection>() { section });
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case SectionType.SinglePlaylist:
|
||||
// if (adapterItems.Where(x => x.SectionTitle == item.SectionTitle).Count() == 0)
|
||||
// {
|
||||
// YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
|
||||
if (instance == null)
|
||||
return;
|
||||
}
|
||||
// PlaylistItemsResource.ListRequest request = youtube.PlaylistItems.List("snippet, contentDetails");
|
||||
// request.PlaylistId = item.contentValue[0];
|
||||
// request.MaxResults = 10;
|
||||
// request.PageToken = "";
|
||||
|
||||
HomeSection section = new HomeSection(item.SectionTitle, item.contentType, contentValue)
|
||||
{
|
||||
data = item.contentValue[0]
|
||||
};
|
||||
// PlaylistItemListResponse response = await request.ExecuteAsync();
|
||||
|
||||
if (adapter == null)
|
||||
{
|
||||
adapterItems.Add(section);
|
||||
adapter = new HomeAdapter(adapterItems);
|
||||
ListView.SetAdapter(adapter);
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
adapter.ItemLongClick += ListView_ItemLongCLick;
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
}
|
||||
else
|
||||
{
|
||||
adapterItems.Add(section);
|
||||
adapter.AddToList(new List<HomeSection>() { section });
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SectionType.PlaylistList:
|
||||
if (adapterItems.Where(x => x.SectionTitle == item.SectionTitle).Count() == 0)
|
||||
{
|
||||
foreach (string playlistID in item.contentValue)
|
||||
{
|
||||
YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
// foreach (var ytItem in response.Items)
|
||||
// {
|
||||
// Song song = new Song(ytItem.Snippet.Title, ytItem.Snippet.ChannelTitle, ytItem.Snippet.Thumbnails.High.Url, ytItem.ContentDetails.VideoId, -1, -1, ytItem.ContentDetails.VideoId, true);
|
||||
// contentValue.Add(song);
|
||||
|
||||
PlaylistsResource.ListRequest request = youtube.Playlists.List("snippet, contentDetails");
|
||||
request.Id = playlistID;
|
||||
// if (instance == null)
|
||||
// return;
|
||||
// }
|
||||
|
||||
PlaylistListResponse response = await request.ExecuteAsync();
|
||||
// HomeSection section = new HomeSection(item.SectionTitle, item.contentType, contentValue)
|
||||
// {
|
||||
// data = item.contentValue[0]
|
||||
// };
|
||||
|
||||
// if (adapter == null)
|
||||
// {
|
||||
// adapterItems.Add(section);
|
||||
// adapter = new HomeAdapter(adapterItems);
|
||||
// ListView.SetAdapter(adapter);
|
||||
// adapter.ItemClick += ListView_ItemClick;
|
||||
// adapter.ItemLongClick += ListView_ItemLongCLick;
|
||||
// ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
// ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// adapterItems.Add(section);
|
||||
// adapter.AddToList(new List<HomeSection>() { section });
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case SectionType.PlaylistList:
|
||||
// if (adapterItems.Where(x => x.SectionTitle == item.SectionTitle).Count() == 0)
|
||||
// {
|
||||
// foreach (string playlistID in item.contentValue)
|
||||
// {
|
||||
// YouTubeService youtube = YoutubeEngine.youtubeService;
|
||||
|
||||
// PlaylistsResource.ListRequest request = youtube.Playlists.List("snippet, contentDetails");
|
||||
// request.Id = playlistID;
|
||||
|
||||
// PlaylistListResponse response = await request.ExecuteAsync();
|
||||
|
||||
|
||||
foreach (var playlist in response.Items)
|
||||
{
|
||||
Console.WriteLine("&" + playlist.Snippet.Title);
|
||||
Song song = new Song(playlist.Snippet.Title, playlist.Snippet.ChannelTitle, playlist.Snippet.Thumbnails.Default__.Url, playlist.Id, -1, -1, playlist.Id, true);
|
||||
contentValue.Add(song);
|
||||
// foreach (var playlist in response.Items)
|
||||
// {
|
||||
// Console.WriteLine("&" + playlist.Snippet.Title);
|
||||
// Song song = new Song(playlist.Snippet.Title, playlist.Snippet.ChannelTitle, playlist.Snippet.Thumbnails.Default__.Url, playlist.Id, -1, -1, playlist.Id, true);
|
||||
// contentValue.Add(song);
|
||||
|
||||
if (instance == null)
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (instance == null)
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
HomeSection section = new HomeSection(item.SectionTitle, item.contentType, contentValue);
|
||||
if (adapter == null)
|
||||
{
|
||||
adapterItems.Add(section);
|
||||
adapter = new HomeAdapter(adapterItems);
|
||||
ListView.SetAdapter(adapter);
|
||||
adapter.ItemClick += ListView_ItemClick;
|
||||
adapter.ItemLongClick += ListView_ItemLongCLick;
|
||||
ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
}
|
||||
else
|
||||
{
|
||||
adapterItems.Add(section);
|
||||
adapter.AddToList(new List<HomeSection>() { section });
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// HomeSection section = new HomeSection(item.SectionTitle, item.contentType, contentValue);
|
||||
// if (adapter == null)
|
||||
// {
|
||||
// adapterItems.Add(section);
|
||||
// adapter = new HomeAdapter(adapterItems);
|
||||
// ListView.SetAdapter(adapter);
|
||||
// adapter.ItemClick += ListView_ItemClick;
|
||||
// adapter.ItemLongClick += ListView_ItemLongCLick;
|
||||
// ListView.SetItemAnimator(new DefaultItemAnimator());
|
||||
// ListView.ScrollChange += MainActivity.instance.Scroll;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// adapterItems.Add(section);
|
||||
// adapter.AddToList(new List<HomeSection>() { section });
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (instance == null)
|
||||
return;
|
||||
//if (instance == null)
|
||||
// return;
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static Fragment NewInstance()
|
||||
@@ -286,48 +300,48 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
private void ListView_ItemClick(object sender, int position)
|
||||
{
|
||||
int pos = adapter.GetItemPosition(position, out int ContainerID);
|
||||
HomeSection section = adapterItems[ContainerID];
|
||||
Song item = section.contentValue[pos];
|
||||
//int pos = adapter.GetItemPosition(position, out int ContainerID);
|
||||
//HomeSection section = adapterItems[ContainerID];
|
||||
//Song item = section.contentValue[pos];
|
||||
|
||||
if(pos == 0)
|
||||
{
|
||||
if (section.contentType == SectionType.SinglePlaylist)
|
||||
{
|
||||
MainActivity.parcelableSender = "Home";
|
||||
MainActivity.parcelable = ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
//if(pos == 0)
|
||||
//{
|
||||
// if (section.contentType == SectionType.SinglePlaylist)
|
||||
// {
|
||||
// MainActivity.parcelableSender = "Home";
|
||||
// MainActivity.parcelable = ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
|
||||
AppCompatActivity act = (AppCompatActivity)Activity;
|
||||
act.SupportActionBar.SetHomeButtonEnabled(true);
|
||||
act.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
act.SupportActionBar.Title = section.SectionTitle;
|
||||
// AppCompatActivity act = (AppCompatActivity)Activity;
|
||||
// act.SupportActionBar.SetHomeButtonEnabled(true);
|
||||
// act.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
// act.SupportActionBar.Title = section.SectionTitle;
|
||||
|
||||
MainActivity.instance.HideTabs();
|
||||
MainActivity.instance.HomeDetails = true;
|
||||
MainActivity.instance.Transition(Resource.Id.contentView, PlaylistTracks.NewInstance(section.data, item.GetName(), false, item.GetArtist(), -1, item.GetAlbum()), true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (section.contentType == SectionType.SinglePlaylist)
|
||||
{
|
||||
YoutubeEngine.Play(item.youtubeID, item.GetName(), item.GetArtist(), item.GetAlbum());
|
||||
}
|
||||
else if (section.contentType == SectionType.PlaylistList)
|
||||
{
|
||||
MainActivity.parcelableSender = "Home";
|
||||
MainActivity.parcelable = ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
// MainActivity.instance.HideTabs();
|
||||
// MainActivity.instance.HomeDetails = true;
|
||||
// MainActivity.instance.Transition(Resource.Id.contentView, PlaylistTracks.NewInstance(section.data, item.GetName(), false, item.GetArtist(), -1, item.GetAlbum()), true);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (section.contentType == SectionType.SinglePlaylist)
|
||||
// {
|
||||
// YoutubeEngine.Play(item.youtubeID, item.GetName(), item.GetArtist(), item.GetAlbum());
|
||||
// }
|
||||
// else if (section.contentType == SectionType.PlaylistList)
|
||||
// {
|
||||
// MainActivity.parcelableSender = "Home";
|
||||
// MainActivity.parcelable = ListView.GetLayoutManager().OnSaveInstanceState();
|
||||
|
||||
AppCompatActivity act = (AppCompatActivity)Activity;
|
||||
act.SupportActionBar.SetHomeButtonEnabled(true);
|
||||
act.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
act.SupportActionBar.Title = section.SectionTitle;
|
||||
// AppCompatActivity act = (AppCompatActivity)Activity;
|
||||
// act.SupportActionBar.SetHomeButtonEnabled(true);
|
||||
// act.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
|
||||
// act.SupportActionBar.Title = section.SectionTitle;
|
||||
|
||||
MainActivity.instance.HideTabs();
|
||||
MainActivity.instance.HomeDetails = true;
|
||||
MainActivity.instance.Transition(Resource.Id.contentView, PlaylistTracks.NewInstance(item.youtubeID, item.GetName(), false, item.GetArtist(), -1, item.GetAlbum()), true);
|
||||
}
|
||||
}
|
||||
// MainActivity.instance.HideTabs();
|
||||
// MainActivity.instance.HomeDetails = true;
|
||||
// MainActivity.instance.Transition(Resource.Id.contentView, PlaylistTracks.NewInstance(item.youtubeID, item.GetName(), false, item.GetArtist(), -1, item.GetAlbum()), true);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void ListView_ItemLongCLick(object sender, int e)
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
public class HomeAdapter : RecyclerView.Adapter
|
||||
{
|
||||
public List<HomeSection> items;
|
||||
private bool refreshDisabled = false;
|
||||
private bool refreshDisabled = true;
|
||||
|
||||
public event EventHandler<int> ItemClick;
|
||||
public event EventHandler<int> ItemLongClick;
|
||||
@@ -37,163 +37,20 @@ namespace MusicApp.Resources.Portable_Class
|
||||
NotifyItemRangeInserted(positionStart, items.Count);
|
||||
}
|
||||
|
||||
public override int ItemCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = 0;
|
||||
for(int i = 0; i < items.Count; i++) { count += items[i].contentValue.Count; }
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetItemPosition(int position, out int containerID)
|
||||
{
|
||||
int pos = 0;
|
||||
containerID = 0;
|
||||
for(pos = position; pos - /*(items[containerID].contentType == SectionType.SinglePlaylist ? 2 :*/ items[containerID].contentValue.Count/*)*/ >= 0; pos -= /*(items[containerID - 1].contentType == SectionType.SinglePlaylist ? 2 : */items[containerID - 1].contentValue.Count/*)*/)
|
||||
{
|
||||
if (containerID + 1 < items.Count)
|
||||
{
|
||||
containerID++;
|
||||
//Console.WriteLine("&Switching to the next container, containerID = " + containerID + " pos = " + pos + " Container value count : " + items[containerID]?.contentValue.Count);
|
||||
}
|
||||
}
|
||||
|
||||
//Console.WriteLine("&Container ID : " + containerID + " Item Position : " + pos);
|
||||
return pos;
|
||||
}
|
||||
public override int ItemCount { get { return items.Count; } }
|
||||
|
||||
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
|
||||
{
|
||||
if(viewType == (int)HomeRow.Header)
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Android.Resource.Layout.PreferenceCategory, parent, false);
|
||||
return new HeaderHolder(itemView, OnClick, OnLongClick);
|
||||
}
|
||||
if(viewType == (int)HomeRow.ChannelHolder)
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.ChannelList, parent, false);
|
||||
return new HomeChannelHolder(itemView, OnClick, OnLongClick);
|
||||
}
|
||||
if (viewType == (int)HomeRow.SongHolder)
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.SongList, parent, false);
|
||||
return new HomeHolder(itemView, OnClick, OnLongClick);
|
||||
}
|
||||
if(viewType == (int)HomeRow.MultipleSong)
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.SquareSong, parent, false);
|
||||
return new HomeMultipleSong(itemView, OnClick, OnLongClick);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override int GetItemViewType(int position)
|
||||
{
|
||||
int pos = GetItemPosition(position, out int containerID);
|
||||
if (pos == 0)
|
||||
return (int)HomeRow.Header;
|
||||
else if (items[containerID].contentType == SectionType.PlaylistList)
|
||||
return (int)HomeRow.SongHolder;
|
||||
else if (items[containerID].contentType == SectionType.SinglePlaylist)
|
||||
return (int)HomeRow.MultipleSong;
|
||||
else
|
||||
return (int)HomeRow.ChannelHolder;
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.LineSongs, parent, false);
|
||||
return new LineSongHolder(itemView, OnClick, OnLongClick);
|
||||
}
|
||||
|
||||
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
|
||||
{
|
||||
position = GetItemPosition(position, out int containerID);
|
||||
|
||||
if(position == 0)
|
||||
{
|
||||
HeaderHolder holder = (HeaderHolder)viewHolder;
|
||||
holder.headerText.Text = items[containerID].SectionTitle;
|
||||
}
|
||||
else if(items[containerID].contentType == SectionType.ChannelList)
|
||||
{
|
||||
HomeChannelHolder holder = (HomeChannelHolder)viewHolder;
|
||||
|
||||
holder.Title.Text = items[containerID].contentValue[position].GetName();
|
||||
holder.Artist.Text = items[containerID].contentValue[position].GetArtist();
|
||||
holder.CheckBox.Visibility = ViewStates.Gone;
|
||||
|
||||
Picasso.With(Application.Context).Load(items[containerID].contentValue[position].GetAlbum()).Placeholder(Resource.Drawable.MusicIcon).Transform(new CircleTransformation()).Into(holder.AlbumArt);
|
||||
|
||||
if (MainActivity.Theme == 1)
|
||||
{
|
||||
holder.Title.SetTextColor(Color.White);
|
||||
holder.Artist.SetTextColor(Color.White);
|
||||
holder.Artist.Alpha = 0.7f;
|
||||
}
|
||||
}
|
||||
else if(items[containerID].contentType == SectionType.SinglePlaylist)
|
||||
{
|
||||
HomeMultipleSong holder = (HomeMultipleSong)viewHolder;
|
||||
|
||||
holder.Title.Text = items[containerID].contentValue[position].GetName();
|
||||
holder.Artist.Text = items[containerID].contentValue[position].GetArtist();
|
||||
|
||||
int width = MainActivity.instance.Resources.DisplayMetrics.WidthPixels - (int)((20 - 0.5f) / MainActivity.instance.Resources.DisplayMetrics.Density);
|
||||
int height = width / 16 * 9;
|
||||
Picasso.With(Application.Context).Load(items[containerID].contentValue[position].GetAlbum()).Placeholder(Resource.Drawable.MusicIcon).Resize(width, height).CenterCrop().Into(holder.AlbumArt);
|
||||
|
||||
holder.more.Tag = position;
|
||||
if (!holder.more.HasOnClickListeners)
|
||||
{
|
||||
holder.more.Click += (sender, e) =>
|
||||
{
|
||||
int tagPosition = (int)((ImageView)sender).Tag;
|
||||
//Home.instance.More(items[tagPosition]);
|
||||
};
|
||||
}
|
||||
|
||||
if (MainActivity.Theme == 1)
|
||||
{
|
||||
holder.Title.SetTextColor(Color.White);
|
||||
holder.Artist.SetTextColor(Color.White);
|
||||
holder.Artist.Alpha = 0.7f;
|
||||
holder.more.SetColorFilter(Color.White);
|
||||
}
|
||||
|
||||
if (MainActivity.Theme == 0)
|
||||
holder.ItemView.SetBackgroundColor(Color.White);
|
||||
else
|
||||
holder.ItemView.SetBackgroundColor(Color.ParseColor("#424242"));
|
||||
}
|
||||
else
|
||||
{
|
||||
HomeHolder holder = (HomeHolder)viewHolder;
|
||||
|
||||
holder.Title.Text = items[containerID].contentValue[position].GetName();
|
||||
holder.Artist.Text = items[containerID].contentValue[position].GetArtist();
|
||||
|
||||
Picasso.With(Application.Context).Load(items[containerID].contentValue[position].GetAlbum()).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(holder.AlbumArt);
|
||||
|
||||
//holder.more.Tag = position;
|
||||
//if (!holder.more.HasOnClickListeners)
|
||||
//{
|
||||
// holder.more.Click += (sender, e) =>
|
||||
// {
|
||||
// int tagPosition = (int)((ImageView)sender).Tag;
|
||||
// Home.instance.More(items[tagPosition]);
|
||||
// };
|
||||
//}
|
||||
|
||||
if (MainActivity.Theme == 1)
|
||||
{
|
||||
holder.more.SetColorFilter(Color.White);
|
||||
holder.Title.SetTextColor(Color.White);
|
||||
holder.Artist.SetTextColor(Color.White);
|
||||
holder.Artist.Alpha = 0.7f;
|
||||
}
|
||||
|
||||
if (MainActivity.Theme == 0)
|
||||
holder.ItemView.SetBackgroundColor(Color.White);
|
||||
else
|
||||
holder.ItemView.SetBackgroundColor(Color.ParseColor("#424242"));
|
||||
}
|
||||
LineSongHolder holder = (LineSongHolder)viewHolder;
|
||||
holder.title.Text = items[position].SectionTitle;
|
||||
holder.recycler.SetLayoutManager(new LinearLayoutManager(MainActivity.instance, LinearLayoutManager.Horizontal, false));
|
||||
holder.recycler.SetAdapter(new LineAdapter(items[position].contentValue));
|
||||
}
|
||||
|
||||
void OnClick(int position)
|
||||
@@ -216,13 +73,4 @@ namespace MusicApp.Resources.Portable_Class
|
||||
refreshDisabled = disable;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum HomeRow
|
||||
{
|
||||
Header = 0,
|
||||
SongHolder = 1,
|
||||
ChannelHolder = 2,
|
||||
MultipleSong = 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Graphics;
|
||||
using Android.Support.V7.Widget;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using MusicApp.Resources.values;
|
||||
using Square.Picasso;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
public class LineAdapter : RecyclerView.Adapter
|
||||
{
|
||||
public int listPadding = 0;
|
||||
private List<Song> songList;
|
||||
|
||||
public override int ItemCount => songList.Count;
|
||||
|
||||
public LineAdapter(List<Song> songList)
|
||||
{
|
||||
this.songList = songList;
|
||||
}
|
||||
|
||||
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
|
||||
{
|
||||
RecyclerHolder holder = (RecyclerHolder)viewHolder;
|
||||
|
||||
if (songList[position].GetAlbumArt() == -1 || songList[position].IsYt)
|
||||
{
|
||||
var songAlbumArtUri = Android.Net.Uri.Parse(songList[position].GetAlbum());
|
||||
Picasso.With(Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(holder.AlbumArt);
|
||||
}
|
||||
else
|
||||
{
|
||||
var songCover = Android.Net.Uri.Parse("content://media/external/audio/albumart");
|
||||
var songAlbumArtUri = ContentUris.WithAppendedId(songCover, songList[position].GetAlbumArt());
|
||||
|
||||
Picasso.With(Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(holder.AlbumArt);
|
||||
}
|
||||
}
|
||||
|
||||
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
|
||||
{
|
||||
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.LineSong, parent, false);
|
||||
return new RecyclerHolder(itemView, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Android.Graphics;
|
||||
using Android.Support.V7.Widget;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using System;
|
||||
|
||||
namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
public class LineSongHolder : RecyclerView.ViewHolder
|
||||
{
|
||||
public TextView title;
|
||||
public RecyclerView recycler;
|
||||
|
||||
public LineSongHolder(View itemView, Action<int> listener, Action<int> longListener) : base(itemView)
|
||||
{
|
||||
title = itemView.FindViewById<TextView>(Resource.Id.title);
|
||||
recycler = itemView.FindViewById<RecyclerView>(Resource.Id.lineRecycler);
|
||||
|
||||
itemView.Click += (sender, e) => listener(AdapterPosition);
|
||||
itemView.LongClick += (sender, e) => longListener(AdapterPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,7 +389,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
string Artist = musicCursor.GetString(artistID);
|
||||
string Title = musicCursor.GetString(titleID);
|
||||
string Album = musicCursor.GetString(albumID);
|
||||
long AlbumArt = musicCursor.GetLong(musicCursor.GetColumnIndex(MediaStore.Audio.Albums.InterfaceConsts.AlbumId));
|
||||
long AlbumArt = musicCursor.GetLong(musicCursor.GetColumnIndex(Albums.InterfaceConsts.AlbumId));
|
||||
long id = musicCursor.GetLong(thisID);
|
||||
string path = musicCursor.GetString(pathID);
|
||||
|
||||
@@ -411,7 +411,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
songs.RemoveAt(0);
|
||||
songs.Reverse();
|
||||
|
||||
|
||||
while (MusicPlayer.instance == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
((AppBarLayout.LayoutParams)Activity.FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsingToolbar).LayoutParameters).ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll | AppBarLayout.LayoutParams.ScrollFlagExitUntilCollapsed | AppBarLayout.LayoutParams.ScrollFlagSnap;
|
||||
Activity.FindViewById<AppBarLayout>(Resource.Id.appbar).AddOnOffsetChangedListener(this);
|
||||
Activity.FindViewById<TextView>(Resource.Id.headerTitle).Text = playlistName;
|
||||
Activity.FindViewById<ImageButton>(Resource.Id.headerPlay).Click += (sender, e0) => { PlayInOrder(0); };
|
||||
Activity.FindViewById<ImageButton>(Resource.Id.headerPlay).Click += (sender, e0) => { PlayInOrder(0, false); };
|
||||
Activity.FindViewById<ImageButton>(Resource.Id.headerShuffle).Click += (sender, e0) =>
|
||||
{
|
||||
if (playlistId != 0)
|
||||
@@ -406,7 +406,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
|
||||
private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
|
||||
{
|
||||
PlayInOrder(e.Position);
|
||||
PlayInOrder(e.Position, true);
|
||||
}
|
||||
|
||||
private void ListView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
|
||||
@@ -443,7 +443,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
case 0:
|
||||
int Position = tracks.IndexOf(item);
|
||||
PlayInOrder(Position);
|
||||
PlayInOrder(Position, true);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -499,7 +499,7 @@ namespace MusicApp.Resources.Portable_Class
|
||||
{
|
||||
case 0:
|
||||
int Position = tracks.IndexOf(item);
|
||||
PlayInOrder(Position);
|
||||
PlayInOrder(Position, true);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -535,19 +535,19 @@ namespace MusicApp.Resources.Portable_Class
|
||||
builder.Show();
|
||||
}
|
||||
|
||||
async void PlayInOrder(int fromPosition)
|
||||
async void PlayInOrder(int fromPosition, bool useTransition)
|
||||
{
|
||||
List<Song> songs = tracks.GetRange(fromPosition, tracks.Count - fromPosition);
|
||||
if (result != null && result.Count - 1 >= fromPosition)
|
||||
songs = result.GetRange(fromPosition, result.Count - fromPosition);
|
||||
|
||||
if (MusicPlayer.isRunning)
|
||||
MusicPlayer.queue.Clear();
|
||||
MusicPlayer.queue.Clear();
|
||||
MusicPlayer.currentID = -1;
|
||||
|
||||
if (!songs[0].IsYt)
|
||||
{
|
||||
Browse.act = Activity;
|
||||
Browse.Play(songs[0], ListView.GetChildAt(fromPosition - ListView.FirstVisiblePosition).FindViewById<ImageView>(Resource.Id.albumArt));
|
||||
Browse.Play(songs[0], useTransition ? ListView.GetChildAt(fromPosition - ListView.FirstVisiblePosition).FindViewById<ImageView>(Resource.Id.albumArt) : null);
|
||||
}
|
||||
else
|
||||
YoutubeEngine.Play(songs[0].youtubeID, songs[0].GetName(), songs[0].GetArtist(), songs[0].GetAlbum());
|
||||
@@ -558,7 +558,6 @@ namespace MusicApp.Resources.Portable_Class
|
||||
while (MusicPlayer.instance == null)
|
||||
await Task.Delay(10);
|
||||
|
||||
MusicPlayer.currentID = -1;
|
||||
foreach (Song song in songs)
|
||||
{
|
||||
MusicPlayer.instance.AddToQueue(song);
|
||||
|
||||
Generated
+286
-274
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="7dp" >
|
||||
<ImageView
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:id="@+id/albumArt"/>
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:elevation="6dp"
|
||||
android:background="#ffffff"
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/frame">
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="22dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:textColor="?colorAccent"
|
||||
android:textStyle="bold" />
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/lineRecycler" />
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
Reference in New Issue
Block a user