Fix no server call when starring song from notification

This commit is contained in:
Maxence G 2021-06-16 20:27:22 +02:00
parent 2d4c773344
commit d440b8c76d
No known key found for this signature in database
GPG Key ID: DC1FD9409E3FE284
2 changed files with 14 additions and 0 deletions

View File

@ -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() {

View File

@ -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