From b3df9723bc6241d23e5f6d09163f03773deb5e79 Mon Sep 17 00:00:00 2001 From: Anonymous Raccoon <32224410+AnonymusRaccoon@users.noreply.github.com> Date: Thu, 30 Aug 2018 23:40:10 +0200 Subject: [PATCH] Solving a bug with queue switch from the home screen. --- MusicApp/MusicApp.csproj | 28 +++++++++---------- .../Resources/Portable Class/LineAdapter.cs | 18 ++++++++++-- .../Resources/Portable Class/MusicPlayer.cs | 5 +++- .../Portable Class/SearchableActivity.cs | 3 +- MusicApp/packages.config | 18 ++++++------ 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/MusicApp/MusicApp.csproj b/MusicApp/MusicApp.csproj index 69f2757..79e9afa 100644 --- a/MusicApp/MusicApp.csproj +++ b/MusicApp/MusicApp.csproj @@ -76,23 +76,23 @@ ..\packages\Karamunting.Android.AnderWeb.DiscreteSeekBar.1.0.1.1\lib\monoandroid81\DiscreteSeekBar.dll - - ..\packages\Xam.Plugins.Android.ExoPlayer.2.8.7\lib\monoandroid81\ExoPlayer.dll + + ..\packages\Xam.Plugins.Android.ExoPlayer.2.8.8\lib\monoandroid81\ExoPlayer.dll - - ..\packages\Xam.Plugins.Android.ExoPlayer.Core.2.8.7\lib\monoandroid81\ExoPlayer.Core.dll + + ..\packages\Xam.Plugins.Android.ExoPlayer.Core.2.8.8\lib\monoandroid81\ExoPlayer.Core.dll - - ..\packages\Xam.Plugins.Android.ExoPlayer.Dash.2.8.7\lib\monoandroid81\ExoPlayer.Dash.dll + + ..\packages\Xam.Plugins.Android.ExoPlayer.Dash.2.8.8\lib\monoandroid81\ExoPlayer.Dash.dll - - ..\packages\Xam.Plugins.Android.ExoPlayer.Hls.2.8.7\lib\monoandroid81\ExoPlayer.Hls.dll + + ..\packages\Xam.Plugins.Android.ExoPlayer.Hls.2.8.8\lib\monoandroid81\ExoPlayer.Hls.dll - - ..\packages\Xam.Plugins.Android.ExoPlayer.SmoothStreaming.2.8.7\lib\monoandroid81\ExoPlayer.SmoothStreaming.dll + + ..\packages\Xam.Plugins.Android.ExoPlayer.SmoothStreaming.2.8.8\lib\monoandroid81\ExoPlayer.SmoothStreaming.dll - - ..\packages\Xam.Plugins.Android.ExoPlayer.UI.2.8.7\lib\monoandroid81\ExoPlayer.UI.dll + + ..\packages\Xam.Plugins.Android.ExoPlayer.UI.2.8.8\lib\monoandroid81\ExoPlayer.UI.dll ..\packages\Google.Apis.1.35.1\lib\netstandard2.0\Google.Apis.dll @@ -248,8 +248,8 @@ ..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.1\lib\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.dll - - ..\packages\YoutubeExplode.4.3.0\lib\netstandard2.0\YoutubeExplode.dll + + ..\packages\YoutubeExplode.4.3.1\lib\netstandard2.0\YoutubeExplode.dll diff --git a/MusicApp/Resources/Portable Class/LineAdapter.cs b/MusicApp/Resources/Portable Class/LineAdapter.cs index 0111db3..7de531d 100644 --- a/MusicApp/Resources/Portable Class/LineAdapter.cs +++ b/MusicApp/Resources/Portable Class/LineAdapter.cs @@ -63,8 +63,22 @@ namespace MusicApp.Resources.Portable_Class void OnClick(int position) { - if (useQueue && MusicPlayer.instance != null) - MusicPlayer.instance.SwitchQueue(songList[position]); + if (useQueue) + { + if(MusicPlayer.instance != null) + MusicPlayer.instance.SwitchQueue(songList[position]); + else + { + Intent intent = new Intent(MainActivity.instance, typeof(MusicPlayer)); + intent.SetAction("SwitchQueue"); + intent.PutExtra("queueSlot", position); + MainActivity.instance.StartService(intent); + + Intent player = new Intent(MainActivity.instance, typeof(Player)); + MainActivity.instance.StartActivity(player); + } + + } else if (!songList[position].IsYt) Browse.Play(songList[position], recycler.GetLayoutManager().FindViewByPosition(position).FindViewById(Resource.Id.albumArt)); else diff --git a/MusicApp/Resources/Portable Class/MusicPlayer.cs b/MusicApp/Resources/Portable Class/MusicPlayer.cs index ef41340..c043a1f 100644 --- a/MusicApp/Resources/Portable Class/MusicPlayer.cs +++ b/MusicApp/Resources/Portable Class/MusicPlayer.cs @@ -11,7 +11,6 @@ using Android.Support.V4.Content; using Android.Support.V4.Media.Session; using Android.Support.V7.Preferences; using Android.Support.V7.Widget; -using Android.Util; using Android.Views; using Android.Widget; using Com.Google.Android.Exoplayer2; @@ -132,6 +131,10 @@ namespace MusicApp.Resources.Portable_Class case "SleepPause": SleepPause(); break; + + case "SwitchQueue": + SwitchQueue(queue[intent.GetIntExtra("queueSlot", -1)]); + break; } if (intent.Action != null) diff --git a/MusicApp/Resources/Portable Class/SearchableActivity.cs b/MusicApp/Resources/Portable Class/SearchableActivity.cs index 2c9b27b..2c74386 100644 --- a/MusicApp/Resources/Portable Class/SearchableActivity.cs +++ b/MusicApp/Resources/Portable Class/SearchableActivity.cs @@ -82,11 +82,12 @@ namespace MusicApp.Resources.Portable_Class { try { - using (WebClient client = new WebClient()) + using (WebClient client = new WebClient { Encoding = System.Text.Encoding.UTF8 }) { string json = client.DownloadString("http://suggestqueries.google.com/complete/search?client=youtube&ds=yt&client=firefox&q=" + e.NewText); json = json.Substring(4 + e.NewText.Length); json = json.Remove(json.Length - 1); + System.Console.WriteLine("&" + json); List items = JsonConvert.DeserializeObject>(json); suggestions = items.ConvertAll(StringToSugest); suggestions.InsertRange(0, History.Where(x => x.Text.StartsWith(e.NewText))); diff --git a/MusicApp/packages.config b/MusicApp/packages.config index 4aedb6f..6599248 100644 --- a/MusicApp/packages.config +++ b/MusicApp/packages.config @@ -7,7 +7,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -69,12 +69,12 @@ - - - - - - + + + + + + @@ -101,5 +101,5 @@ - + \ No newline at end of file