From d440b8c76de00d68befdb4adc05031b02871ea2d Mon Sep 17 00:00:00 2001 From: Maxence G Date: Wed, 16 Jun 2021 20:27:22 +0200 Subject: [PATCH 1/3] Fix no server call when starring song from notification --- .../moire/ultrasonic/fragment/PlayerFragment.java | 1 + .../ultrasonic/service/MediaPlayerController.kt | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java b/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java index 9b056315..a00aeba5 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java @@ -992,6 +992,7 @@ public class PlayerFragment extends Fragment implements GestureDetector.OnGestur currentSong.setStarred(true); } + // Code is duplicated with MediaPlayerController:457 FIXME: There should be a better way new Thread(new Runnable() { @Override public void run() { diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt index cd0f16c6..9ef5d9d2 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt @@ -454,6 +454,19 @@ class MediaPlayerController( if (localMediaPlayer.currentPlaying == null) return val song = localMediaPlayer.currentPlaying!!.song + Thread { + val musicService = getMusicService() + try { + if (song.starred) { + musicService.unstar(song.id, null, null) + } else { + musicService.star(song.id, null, null) + } + } catch (e: java.lang.Exception) { + Timber.e(e) + } + }.start() + // Trigger an update localMediaPlayer.setCurrentPlaying(localMediaPlayer.currentPlaying) song.starred = !song.starred From 956d555b3503419fbe915fbdd4cf569f38e37b04 Mon Sep 17 00:00:00 2001 From: tzugen <67737443+tzugen@users.noreply.github.com> Date: Sat, 19 Jun 2021 23:23:39 +0200 Subject: [PATCH 2/3] Update PlayerFragment.java --- .../main/java/org/moire/ultrasonic/fragment/PlayerFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java b/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java index a00aeba5..9b056315 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/fragment/PlayerFragment.java @@ -992,7 +992,6 @@ public class PlayerFragment extends Fragment implements GestureDetector.OnGestur currentSong.setStarred(true); } - // Code is duplicated with MediaPlayerController:457 FIXME: There should be a better way new Thread(new Runnable() { @Override public void run() { From 38f1f5f5c6edebf64d50b64e4c0b11c13cb74fa5 Mon Sep 17 00:00:00 2001 From: tzugen <67737443+tzugen@users.noreply.github.com> Date: Sat, 19 Jun 2021 23:25:02 +0200 Subject: [PATCH 3/3] Nicer catch all --- .../org/moire/ultrasonic/service/MediaPlayerController.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt index 9ef5d9d2..ac424e20 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/MediaPlayerController.kt @@ -462,8 +462,8 @@ class MediaPlayerController( } else { musicService.star(song.id, null, null) } - } catch (e: java.lang.Exception) { - Timber.e(e) + } catch (all: Exception) { + Timber.e(all) } }.start()