From b7f636417a8834b9091b2ed41756f013c3095ae3 Mon Sep 17 00:00:00 2001 From: Anonymous Raccoon <32224410+AnonymusRaccoon@users.noreply.github.com> Date: Fri, 6 Jul 2018 23:36:11 +0200 Subject: [PATCH] Solving bugs --- .../Resources/Portable Class/MusicPlayer.cs | 9 ++-- MusicApp/Resources/Portable Class/Player.cs | 2 +- MusicApp/Resources/Portable Class/Playlist.cs | 1 - .../Portable Class/PlaylistTracks.cs | 51 +++---------------- .../Portable Class/RecyclerAdapter.cs | 28 +++++----- .../Resources/Portable Class/YoutubeEngine.cs | 19 +------ 6 files changed, 27 insertions(+), 83 deletions(-) diff --git a/MusicApp/Resources/Portable Class/MusicPlayer.cs b/MusicApp/Resources/Portable Class/MusicPlayer.cs index fcafcc4..b289925 100644 --- a/MusicApp/Resources/Portable Class/MusicPlayer.cs +++ b/MusicApp/Resources/Portable Class/MusicPlayer.cs @@ -222,8 +222,6 @@ namespace MusicApp.Resources.Portable_Class if (song.queueSlot == -1) { - song.queueSlot = CurrentID() + 1; - if (queue.Exists(x => x.queueSlot == CurrentID() + 1) && queue.Find(x => x.queueSlot == CurrentID() + 1) != song) { foreach (Song item in queue) @@ -234,6 +232,8 @@ namespace MusicApp.Resources.Portable_Class } } } + + song.queueSlot = CurrentID() + 1; } Console.WriteLine("&QueueSlot = " + song.queueSlot + "Title = " + song.GetName()); @@ -310,8 +310,6 @@ namespace MusicApp.Resources.Portable_Class if (song.queueSlot == -1) { - song.queueSlot = CurrentID() + 1; - if (queue.Exists(x => x.queueSlot == CurrentID() + 1) && queue.Find(x => x.queueSlot == CurrentID() + 1) != song) { foreach (Song item in queue) @@ -322,8 +320,9 @@ namespace MusicApp.Resources.Portable_Class } } } - } + song.queueSlot = CurrentID() + 1; + } currentID = song.queueSlot; diff --git a/MusicApp/Resources/Portable Class/Player.cs b/MusicApp/Resources/Portable Class/Player.cs index f13fceb..f93d227 100644 --- a/MusicApp/Resources/Portable Class/Player.cs +++ b/MusicApp/Resources/Portable Class/Player.cs @@ -469,7 +469,7 @@ namespace MusicApp.Resources.Portable_Class Console.WriteLine("&Going to sleep in " + time + ", slected item is the " + checkedItem + " one."); Intent intent = new Intent(this, typeof(Sleeper)); intent.PutExtra("time", time); - this.StartService(intent); + StartService(intent); } protected override void OnResume() diff --git a/MusicApp/Resources/Portable Class/Playlist.cs b/MusicApp/Resources/Portable Class/Playlist.cs index 23a5ff5..03116fa 100644 --- a/MusicApp/Resources/Portable Class/Playlist.cs +++ b/MusicApp/Resources/Portable Class/Playlist.cs @@ -2,7 +2,6 @@ using Android.Database; using Android.OS; using Android.Provider; -using Android.Support.Design.Widget; using Android.Support.V4.App; using Android.Support.V7.App; using Android.Support.V7.Widget; diff --git a/MusicApp/Resources/Portable Class/PlaylistTracks.cs b/MusicApp/Resources/Portable Class/PlaylistTracks.cs index 7e891b9..abb5977 100644 --- a/MusicApp/Resources/Portable Class/PlaylistTracks.cs +++ b/MusicApp/Resources/Portable Class/PlaylistTracks.cs @@ -220,43 +220,6 @@ namespace MusicApp.Resources.Portable_Class Activity.FindViewById(Resource.Id.playlistHeader).Visibility = ViewStates.Gone; MainActivity.instance.SupportFragmentManager.PopBackStack(); - - //if (MainActivity.instance.HomeDetails) - //{ - // Home.instance = null; - // MainActivity.instance.Navigate(Resource.Id.musicLayout); - // MainActivity.instance.HomeDetails = false; - //} - //else if (MainActivity.youtubeInstanceSave != null) - //{ - // int selectedTab = 0; - // switch (MainActivity.youtubeInstanceSave) - // { - // case "YoutubeEngine-All": - // selectedTab = 0; - // break; - // case "YoutubeEngine-Tracks": - // selectedTab = 1; - // break; - // case "YoutubeEngine-Playlists": - // selectedTab = 2; - // break; - // case "YoutubeEngine-Channels": - // selectedTab = 3; - // break; - // default: - // break; - // } - // MainActivity.instance.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.contentView, Pager.NewInstance(2, selectedTab)).Commit(); - // YoutubeEngine.instances[selectedTab].focused = true; - // YoutubeEngine.instances[selectedTab].OnFocus(); - // YoutubeEngine.instances[selectedTab].ResumeListView(); - //} - //else - //{ - // MainActivity.instance.Navigate(Resource.Id.playlistLayout); - //} - base.OnDestroy(); instance = null; } @@ -295,7 +258,7 @@ namespace MusicApp.Resources.Portable_Class if (playlistId != 0) { - Uri musicUri = MediaStore.Audio.Playlists.Members.GetContentUri("external", playlistId); + Uri musicUri = Playlists.Members.GetContentUri("external", playlistId); CursorLoader cursorLoader = new CursorLoader(Android.App.Application.Context, musicUri, null, null, null, null); ICursor musicCursor = (ICursor)cursorLoader.LoadInBackground(); @@ -304,17 +267,17 @@ namespace MusicApp.Resources.Portable_Class if (musicCursor != null && musicCursor.MoveToFirst()) { - int titleID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Title); - int artistID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Artist); - int albumID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Album); - int thisID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Id); - int pathID = musicCursor.GetColumnIndex(MediaStore.Audio.Media.InterfaceConsts.Data); + int titleID = musicCursor.GetColumnIndex(Media.InterfaceConsts.Title); + int artistID = musicCursor.GetColumnIndex(Media.InterfaceConsts.Artist); + int albumID = musicCursor.GetColumnIndex(Media.InterfaceConsts.Album); + int thisID = musicCursor.GetColumnIndex(Media.InterfaceConsts.Id); + int pathID = musicCursor.GetColumnIndex(Media.InterfaceConsts.Data); do { 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); diff --git a/MusicApp/Resources/Portable Class/RecyclerAdapter.cs b/MusicApp/Resources/Portable Class/RecyclerAdapter.cs index 03f3c5c..570ee82 100644 --- a/MusicApp/Resources/Portable Class/RecyclerAdapter.cs +++ b/MusicApp/Resources/Portable Class/RecyclerAdapter.cs @@ -145,20 +145,20 @@ namespace MusicApp.Resources.Portable_Class else holder.ItemView.SetBackgroundColor(Color.ParseColor("#424242")); - if (position + 1 == songList.Count) - { - holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), listPadding); - LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters; - layoutParams.SetMargins(0, 0, 0, listPadding); - holder.more.LayoutParameters = layoutParams; - } - else - { - holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f)); - LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters; - layoutParams.SetMargins(0, 0, 0, 0); - holder.more.LayoutParameters = layoutParams; - } + //if (position + 1 == songList.Count) + //{ + // holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), listPadding); + // LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters; + // layoutParams.SetMargins(0, 0, 0, listPadding); + // holder.more.LayoutParameters = layoutParams; + //} + //else + //{ + // holder.ItemView.SetPadding((int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f), (int)(8 * scale + 0.5f)); + // LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)holder.more.LayoutParameters; + // layoutParams.SetMargins(0, 0, 0, 0); + // holder.more.LayoutParameters = layoutParams; + //} } public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) diff --git a/MusicApp/Resources/Portable Class/YoutubeEngine.cs b/MusicApp/Resources/Portable Class/YoutubeEngine.cs index 0681ee2..0329b25 100644 --- a/MusicApp/Resources/Portable Class/YoutubeEngine.cs +++ b/MusicApp/Resources/Portable Class/YoutubeEngine.cs @@ -315,23 +315,6 @@ namespace MusicApp.Resources.Portable_Class intent.PutExtra("artist", artist); intent.PutExtra("thumbnailURI", thumbnailURL); Android.App.Application.Context.StartService(intent); - - //if (instance != null) - //{ - // MainActivity.youtubeParcel = instance.ListView.GetLayoutManager().OnSaveInstanceState(); - // MainActivity.youtubeInstanceSave = "YoutubeEngine" + "-" + instance.querryType; - - // ViewGroup rootView = instance.Activity.FindViewById(Android.Resource.Id.Content); - // foreach (YoutubeEngine inst in instances) - // { - // MainActivity.instance.OnPaddingChanged -= inst.OnPaddingChanged; - // rootView.RemoveView(inst.emptyView); - // } - // rootView.RemoveView(loadingView); - // instances = null; - //} - //else - // MainActivity.instance.SaveInstance(); } public static async void PlayFiles(Song[] files) @@ -342,6 +325,7 @@ namespace MusicApp.Resources.Portable_Class if (MusicPlayer.isRunning) MusicPlayer.queue.Clear(); + MusicPlayer.currentID = -1; Play(files[0].GetPath(), files[0].GetName(), files[0].GetArtist(), files[0].GetAlbum()); if (files.Length < 2) @@ -350,7 +334,6 @@ namespace MusicApp.Resources.Portable_Class while (MusicPlayer.instance == null || MusicPlayer.CurrentID() == -1) await Task.Delay(10); - MusicPlayer.currentID = -1; foreach (Song song in files) { MusicPlayer.instance.AddToQueue(song);