Solving topic name bug.

This commit is contained in:
Anonymous Raccoon
2018-07-18 17:38:42 +02:00
parent c113787cc9
commit 89a182976d
10 changed files with 233 additions and 91 deletions
+3
View File
@@ -635,6 +635,9 @@
<ItemGroup>
<AndroidResource Include="Resources\layout\HomeChannel.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\HomePlaylists.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')" />
+21 -5
View File
@@ -113,11 +113,17 @@ namespace MusicApp.Resources.Portable_Class
ListView.SetItemAnimator(new DefaultItemAnimator());
ListView.ScrollChange += MainActivity.instance.Scroll;
List<string> selectedTopics = new List<string>();
List<string> selectedTopicsID = new List<string>();
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Activity);
string[] selectedTopics = prefManager.GetStringSet("selectedTopics", new string[] { }).ToArray();
string[] selectedTopicsID = prefManager.GetStringSet("selectedTopicsID", new string[] { }).ToArray();
List<string> topics = prefManager.GetStringSet("selectedTopics", new string[] { }).ToList();
foreach (string topic in topics)
{
selectedTopics.Add(topic.Substring(0, topic.IndexOf("/#-#/")));
selectedTopicsID.Add(topic.Substring(topic.IndexOf("/#-#/") + 5));
}
if (selectedTopicsID.Length > 0)
if (selectedTopicsID.Count > 0)
{
await MainActivity.instance.WaitForYoutube();
@@ -137,7 +143,13 @@ namespace MusicApp.Resources.Portable_Class
string title = section.Snippet.Title;
if (title == null || title == "")
title = selectedTopics[Array.IndexOf(selectedTopicsID, topic)];
title = selectedTopics[selectedTopicsID.IndexOf(topic)];
if (title == "Popular Artists")
title = (selectedTopics[selectedTopicsID.IndexOf(topic)].Contains(" Music") ? selectedTopics[selectedTopicsID.IndexOf(topic)].Substring(0, selectedTopics[selectedTopicsID.IndexOf(topic)].IndexOf(" Music")) : selectedTopics[selectedTopicsID.IndexOf(topic)]) + "'s Popular Artists";
if (title == "Popular Channels")
continue;
if (Items.Exists(x => x.SectionTitle == title))
continue;
@@ -248,6 +260,7 @@ namespace MusicApp.Resources.Portable_Class
}
section = new HomeSection(item.SectionTitle, item.contentType, contentValue);
List<Song> removedValues = new List<Song>();
for (int i = 0; i < adapter.ItemCount; i++)
{
if(adapter.items[i].contentType == SectionType.ChannelList)
@@ -257,6 +270,7 @@ namespace MusicApp.Resources.Portable_Class
if (section.contentValue.Exists(x => x.GetName().Contains(adapter.items[i].contentValue[j].GetName())))
{
adapter.items[i].contentValue[j].SetArtist(section.contentValue.Find(x => x.GetName().Contains(adapter.items[i].contentValue[j].GetName())).youtubeID);
removedValues.Add(section.contentValue.Find(x => x.GetName().Contains(adapter.items[i].contentValue[j].GetName())));
if (j < 4 && adapter.items[i].recycler != null)
{
RecyclerHolder holder = (RecyclerHolder)adapter.items[i].recycler.GetChildViewHolder(adapter.items[i].recycler.GetLayoutManager().FindViewByPosition(j));
@@ -266,7 +280,9 @@ namespace MusicApp.Resources.Portable_Class
}
}
}
//adapter.AddToList(new List<HomeSection>() { section });
//section.contentValue = section.contentValue.Except(removedValues).ToList();
//if(section.contentValue.Count > 0)
// adapter.AddToList(new List<HomeSection>() { section });
break;
default:
break;
@@ -44,11 +44,16 @@ namespace MusicApp.Resources.Portable_Class
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.LineSongs, parent, false);
return new LineSongHolder(itemView, OnClick, OnLongClick);
}
else
else /*if(viewType == 1)*/
{
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.HomeChannels, parent, false);
return new LineSongHolder(itemView, OnClick, OnLongClick);
}
//else
//{
// View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.HomePlaylists, parent, false);
// return new LineSongHolder(itemView, OnClick, OnLongClick);
//}
}
public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
@@ -106,6 +111,18 @@ namespace MusicApp.Resources.Portable_Class
if (MainActivity.Theme == 1)
holder.ItemView.SetBackgroundColor(Color.Argb(255, 62, 62, 62));
}
//Youtube topics channels don't have playlist list others than artist mixes
//else if (items[position].contentType == SectionType.PlaylistList)
//{
// LineSongHolder holder = (LineSongHolder)viewHolder;
// holder.title.Text = items[position].SectionTitle;
// holder.recycler.SetLayoutManager(new LinearLayoutManager(MainActivity.instance, LinearLayoutManager.Vertical, false));
// holder.recycler.SetAdapter(new HomeChannelAdapter(items[position].contentValue.GetRange(0, items[position].contentValue.Count > 4 ? 4 : items[position].contentValue.Count), holder.recycler));
// if (MainActivity.Theme == 1)
// holder.ItemView.SetBackgroundColor(Color.Argb(255, 62, 62, 62));
//}
}
void OnClick(int position)
@@ -132,8 +149,10 @@ namespace MusicApp.Resources.Portable_Class
{
if (items[position].contentType == SectionType.SinglePlaylist)
return 0;
else
else if (items[position].contentType == SectionType.ChannelList)
return 1;
else
return 2;
}
}
}
@@ -1,7 +1,6 @@
using Android.App;
using Android.Support.V7.Widget;
using Android.Views;
using Android.Widget;
using MusicApp.Resources.values;
using Square.Picasso;
using System.Collections.Generic;
@@ -14,7 +13,6 @@ namespace MusicApp.Resources.Portable_Class
public int listPadding = 0;
public List<Song> songList;
private readonly string[] actions = new string[] { "Play", "Play Next", "Play Last", "Add To Playlist", "Edit Metadata" };
public override int ItemCount => songList.Count;
public HomeChannelAdapter(List<Song> songList, RecyclerView recycler)
@@ -50,17 +48,8 @@ namespace MusicApp.Resources.Portable_Class
return new RecyclerHolder(itemView, OnClick, OnLongClick);
}
void OnClick(int position)
{
if (!songList[position].IsYt)
Browse.Play(songList[position], recycler.GetLayoutManager().FindViewByPosition(position).FindViewById<ImageView>(Resource.Id.albumArt));
else
YoutubeEngine.Play(songList[position].youtubeID, songList[position].GetName(), songList[position].GetArtist(), songList[position].GetAlbum());
}
void OnClick(int position) { }
void OnLongClick(int position)
{
}
void OnLongClick(int position) { }
}
}
@@ -6,6 +6,7 @@ using Android.Widget;
using MusicApp.Resources.values;
using Square.Picasso;
using System.Collections.Generic;
using System.Linq;
namespace MusicApp.Resources.Portable_Class
{
@@ -15,7 +16,7 @@ namespace MusicApp.Resources.Portable_Class
public int listPadding = 0;
private List<Song> songList;
private readonly string[] actions = new string[] { "Play", "Play Next", "Play Last", "Add To Playlist", "Edit Metadata" };
private readonly string[] actions = new string[] { "Play", "Play Next", "Play Last", "Add To Playlist" };
public override int ItemCount => songList.Count;
public LineAdapter(List<Song> songList, RecyclerView recycler)
@@ -60,7 +61,67 @@ namespace MusicApp.Resources.Portable_Class
void OnLongClick(int position)
{
Song item = songList[position];
List<string> action = actions.ToList();
if (!item.IsYt)
{
action.Add("Edit Metadata");
Browse.act = MainActivity.instance;
Browse.inflater = MainActivity.instance.LayoutInflater;
}
else
{
action.Add("Download");
}
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.instance, MainActivity.dialogTheme);
builder.SetTitle("Pick an action");
builder.SetItems(action.ToArray(), (senderAlert, args) =>
{
switch (args.Which)
{
case 0:
if (!item.IsYt)
Browse.Play(item, recycler.GetLayoutManager().FindViewByPosition(position).FindViewById<ImageView>(Resource.Id.albumArt));
else
YoutubeEngine.Play(item.youtubeID, item.GetName(), item.GetArtist(), item.GetAlbum());
break;
case 1:
if (!item.IsYt)
Browse.PlayNext(item);
else
YoutubeEngine.PlayNext(item.GetPath(), item.GetName(), item.GetArtist(), item.GetAlbum());
break;
case 2:
if (!item.IsYt)
Browse.PlayLast(item);
else
YoutubeEngine.PlayLast(item.GetPath(), item.GetName(), item.GetArtist(), item.GetAlbum());
break;
case 3:
if (item.IsYt)
YoutubeEngine.GetPlaylists(item.GetPath(), MainActivity.instance);
else
Browse.GetPlaylist(item);
break;
case 5:
if (item.IsYt)
YoutubeEngine.Download(item.GetName(), item.GetPath());
else
Browse.EditMetadata(item, "PlaylistTracks", Home.instance.ListView.GetLayoutManager().OnSaveInstanceState());
break;
default:
break;
}
});
builder.Show();
}
}
}
@@ -473,7 +473,7 @@ namespace MusicApp.Resources.Portable_Class
{
case 0:
int Position = tracks.IndexOf(item);
PlayInOrder(Position, true);
PlayInOrder(Position, true);
break;
case 1:
@@ -505,7 +505,10 @@ namespace MusicApp.Resources.Portable_Class
break;
case 4:
YoutubeEngine.GetPlaylists(item.GetPath(), Activity);
if (item.IsYt)
YoutubeEngine.GetPlaylists(item.GetPath(), Activity);
else
Browse.GetPlaylist(item);
break;
case 5:
@@ -529,7 +532,7 @@ namespace MusicApp.Resources.Portable_Class
{
case 0:
int Position = tracks.IndexOf(item);
PlayInOrder(Position, true);
PlayInOrder(Position, true);
break;
case 1:
@@ -547,7 +550,10 @@ namespace MusicApp.Resources.Portable_Class
break;
case 3:
YoutubeEngine.GetPlaylists(item.GetPath(), Activity);
if (item.IsYt)
YoutubeEngine.GetPlaylists(item.GetPath(), Activity);
else
Browse.GetPlaylist(item);
break;
case 4:
@@ -67,8 +67,12 @@ namespace MusicApp.Resources.Portable_Class
{
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(this);
ISharedPreferencesEditor editor = prefManager.Edit();
editor.PutStringSet("selectedTopics", TopicSelector.instance.selectedTopics);
editor.PutStringSet("selectedTopicsID", TopicSelector.instance.selectedTopicsID);
List<string> topics = new List<string>();
for (int i = 0; i < TopicSelector.instance.selectedTopics.Count; i++)
{
topics.Add(TopicSelector.instance.selectedTopics[i] + "/#-#/" + TopicSelector.instance.selectedTopicsID[i]);
}
editor.PutStringSet("selectedTopics", topics);
editor.Apply();
TopicSelector.instance = null;
Recreate();
@@ -35,8 +35,12 @@ namespace MusicApp.Resources.Portable_Class
List<Song> channelLits = new List<Song>();
ISharedPreferences prefManager = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
selectedTopics = prefManager.GetStringSet("selectedTopics", new string[] { }).ToList();
selectedTopicsID = prefManager.GetStringSet("selectedTopicsID", new string[] { }).ToList();
List<string> topics = prefManager.GetStringSet("selectedTopics", new string[] { }).ToList();
foreach(string topic in topics)
{
selectedTopics.Add(topic.Substring(0, topic.IndexOf("/#-#/")));
selectedTopicsID.Add(topic.Substring(topic.IndexOf("/#-#/") + 5));
}
string nextPageToken = "";
while (nextPageToken != null)
@@ -52,7 +56,6 @@ namespace MusicApp.Resources.Portable_Class
foreach (var item in response.Items)
{
Song channel = new Song(item.Snippet.Title.Substring(0, item.Snippet.Title.IndexOf(" - Topic")), item.Snippet.Description, item.Snippet.Thumbnails.Default__.Url, item.Snippet.ResourceId.ChannelId, -1, -1, null, true);
System.Console.WriteLine("&Channel Name: " + channel.GetName());
channelLits.Add(channel);
}
+63 -60
View File
@@ -4261,184 +4261,187 @@ namespace MusicApp
public const int HomeChannels = 2130903096;
// aapt resource value: 0x7f030039
public const int LineSong = 2130903097;
public const int HomePlaylists = 2130903097;
// aapt resource value: 0x7f03003a
public const int LineSongs = 2130903098;
public const int LineSong = 2130903098;
// aapt resource value: 0x7f03003b
public const int ListPopupLayout = 2130903099;
public const int LineSongs = 2130903099;
// aapt resource value: 0x7f03003c
public const int LogOutButton = 2130903100;
public const int ListPopupLayout = 2130903100;
// aapt resource value: 0x7f03003d
public const int Main = 2130903101;
public const int LogOutButton = 2130903101;
// aapt resource value: 0x7f03003e
public const int MusicLayout = 2130903102;
public const int Main = 2130903102;
// aapt resource value: 0x7f03003f
public const int NoPlaylist = 2130903103;
public const int MusicLayout = 2130903103;
// aapt resource value: 0x7f030040
public const int NoQueue = 2130903104;
public const int NoPlaylist = 2130903104;
// aapt resource value: 0x7f030041
public const int NoSong = 2130903105;
public const int NoQueue = 2130903105;
// aapt resource value: 0x7f030042
public const int notification_action = 2130903106;
public const int NoSong = 2130903106;
// aapt resource value: 0x7f030043
public const int notification_action_tombstone = 2130903107;
public const int notification_action = 2130903107;
// aapt resource value: 0x7f030044
public const int notification_media_action = 2130903108;
public const int notification_action_tombstone = 2130903108;
// aapt resource value: 0x7f030045
public const int notification_media_cancel_action = 2130903109;
public const int notification_media_action = 2130903109;
// aapt resource value: 0x7f030046
public const int notification_template_big_media = 2130903110;
public const int notification_media_cancel_action = 2130903110;
// aapt resource value: 0x7f030047
public const int notification_template_big_media_custom = 2130903111;
public const int notification_template_big_media = 2130903111;
// aapt resource value: 0x7f030048
public const int notification_template_big_media_narrow = 2130903112;
public const int notification_template_big_media_custom = 2130903112;
// aapt resource value: 0x7f030049
public const int notification_template_big_media_narrow_custom = 2130903113;
public const int notification_template_big_media_narrow = 2130903113;
// aapt resource value: 0x7f03004a
public const int notification_template_custom_big = 2130903114;
public const int notification_template_big_media_narrow_custom = 2130903114;
// aapt resource value: 0x7f03004b
public const int notification_template_icon_group = 2130903115;
public const int notification_template_custom_big = 2130903115;
// aapt resource value: 0x7f03004c
public const int notification_template_lines_media = 2130903116;
public const int notification_template_icon_group = 2130903116;
// aapt resource value: 0x7f03004d
public const int notification_template_media = 2130903117;
public const int notification_template_lines_media = 2130903117;
// aapt resource value: 0x7f03004e
public const int notification_template_media_custom = 2130903118;
public const int notification_template_media = 2130903118;
// aapt resource value: 0x7f03004f
public const int notification_template_part_chronometer = 2130903119;
public const int notification_template_media_custom = 2130903119;
// aapt resource value: 0x7f030050
public const int notification_template_part_time = 2130903120;
public const int notification_template_part_chronometer = 2130903120;
// aapt resource value: 0x7f030051
public const int NoYtPlaylist = 2130903121;
public const int notification_template_part_time = 2130903121;
// aapt resource value: 0x7f030052
public const int player = 2130903122;
public const int NoYtPlaylist = 2130903122;
// aapt resource value: 0x7f030053
public const int playerInfo = 2130903123;
public const int player = 2130903123;
// aapt resource value: 0x7f030054
public const int PlaylistHeader = 2130903124;
public const int playerInfo = 2130903124;
// aapt resource value: 0x7f030055
public const int PlaylistList = 2130903125;
public const int PlaylistHeader = 2130903125;
// aapt resource value: 0x7f030056
public const int preference = 2130903126;
public const int PlaylistList = 2130903126;
// aapt resource value: 0x7f030057
public const int preference_category = 2130903127;
public const int preference = 2130903127;
// aapt resource value: 0x7f030058
public const int preference_dialog_edittext = 2130903128;
public const int preference_category = 2130903128;
// aapt resource value: 0x7f030059
public const int preference_dropdown = 2130903129;
public const int preference_dialog_edittext = 2130903129;
// aapt resource value: 0x7f03005a
public const int preference_information = 2130903130;
public const int preference_dropdown = 2130903130;
// aapt resource value: 0x7f03005b
public const int preference_list_fragment = 2130903131;
public const int preference_information = 2130903131;
// aapt resource value: 0x7f03005c
public const int preference_recyclerview = 2130903132;
public const int preference_list_fragment = 2130903132;
// aapt resource value: 0x7f03005d
public const int preference_widget_checkbox = 2130903133;
public const int preference_recyclerview = 2130903133;
// aapt resource value: 0x7f03005e
public const int preference_widget_seekbar = 2130903134;
public const int preference_widget_checkbox = 2130903134;
// aapt resource value: 0x7f03005f
public const int preference_widget_switch_compat = 2130903135;
public const int preference_widget_seekbar = 2130903135;
// aapt resource value: 0x7f030060
public const int PreferenceContent = 2130903136;
public const int preference_widget_switch_compat = 2130903136;
// aapt resource value: 0x7f030061
public const int Preferences = 2130903137;
public const int PreferenceContent = 2130903137;
// aapt resource value: 0x7f030062
public const int PreferenceToolbar = 2130903138;
public const int Preferences = 2130903138;
// aapt resource value: 0x7f030063
public const int QuickPlayLayout = 2130903139;
public const int PreferenceToolbar = 2130903139;
// aapt resource value: 0x7f030064
public const int RecyclerFragment = 2130903140;
public const int QuickPlayLayout = 2130903140;
// aapt resource value: 0x7f030065
public const int SaveAPlaylist = 2130903141;
public const int RecyclerFragment = 2130903141;
// aapt resource value: 0x7f030066
public const int search_layout = 2130903142;
public const int SaveAPlaylist = 2130903142;
// aapt resource value: 0x7f030067
public const int SeekbarPreference = 2130903143;
public const int search_layout = 2130903143;
// aapt resource value: 0x7f030068
public const int select_dialog_item_material = 2130903144;
public const int SeekbarPreference = 2130903144;
// aapt resource value: 0x7f030069
public const int select_dialog_multichoice_material = 2130903145;
public const int select_dialog_item_material = 2130903145;
// aapt resource value: 0x7f03006a
public const int select_dialog_singlechoice_material = 2130903146;
public const int select_dialog_multichoice_material = 2130903146;
// aapt resource value: 0x7f03006b
public const int SmallPlayer = 2130903147;
public const int select_dialog_singlechoice_material = 2130903147;
// aapt resource value: 0x7f03006c
public const int SongList = 2130903148;
public const int SmallPlayer = 2130903148;
// aapt resource value: 0x7f03006d
public const int SquareSong = 2130903149;
public const int SongList = 2130903149;
// aapt resource value: 0x7f03006e
public const int support_simple_spinner_dropdown_item = 2130903150;
public const int SquareSong = 2130903150;
// aapt resource value: 0x7f03006f
public const int tabs = 2130903151;
public const int support_simple_spinner_dropdown_item = 2130903151;
// aapt resource value: 0x7f030070
public const int TimerLayout = 2130903152;
public const int tabs = 2130903152;
// aapt resource value: 0x7f030071
public const int tooltip = 2130903153;
public const int TimerLayout = 2130903153;
// aapt resource value: 0x7f030072
public const int TwoLineLayout = 2130903154;
public const int tooltip = 2130903154;
// aapt resource value: 0x7f030073
public const int ViewPager = 2130903155;
public const int TwoLineLayout = 2130903155;
// aapt resource value: 0x7f030074
public const int YtList = 2130903156;
public const int ViewPager = 2130903156;
// aapt resource value: 0x7f030075
public const int YtList = 2130903157;
static Layout()
{
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:elevation="6dp"
android:background="#fafafa"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22dp"
android:paddingLeft="20dp"
android:layout_centerVertical="true"
android:textStyle="bold"
android:layout_alignParentLeft="true"/>
<Button
android:id="@+id/viewMore"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="More"
app:backgroundTint="?colorAccent"
android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lineRecycler" />
</LinearLayout>