diff --git a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt index 80e650c36..685022df0 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt @@ -161,7 +161,7 @@ class PlaybackStateManager private constructor() { // Increment the index, if it cannot be incremented any further, then // repeat and pause/resume playback depending on the setting if (index < mutableQueue.lastIndex) { - goto(++index, true) + goto(index.inc(), true) } else { goto(0, repeatMode == RepeatMode.ALL) } @@ -174,7 +174,7 @@ class PlaybackStateManager private constructor() { rewind() isPlaying = true } else { - goto(max(--index, 0), true) + goto(max(index.dec(), 0), true) } } @@ -187,13 +187,13 @@ class PlaybackStateManager private constructor() { /** Add a [song] to the top of the queue. */ fun playNext(song: Song) { - mutableQueue.add(++index, song) + mutableQueue.add(index.inc(), song) notifyQueueChanged() } /** Add a list of [songs] to the top of the queue. */ fun playNext(songs: List) { - mutableQueue.addAll(++index, songs) + mutableQueue.addAll(index.inc(), songs) notifyQueueChanged() } diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt index a8e836b28..1f1160987 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt @@ -65,7 +65,8 @@ import org.oxycblt.auxio.widgets.WidgetProvider * therefore there's no need to bind to it to deliver commands. * @author OxygenCobalt * - * TODO: Synchronize components in a less awful way. + * TODO: Synchronize components in a less awful way (Fix issue where rapid-fire updates results + * in a desynced notification) */ class PlaybackService : Service(), Player.Listener, PlaybackStateManager.Callback, SettingsManager.Callback { @@ -374,7 +375,6 @@ class PlaybackService : if (!isForeground) { startForeground(IntegerTable.NOTIFICATION_CODE, notificationComponent.build()) - isForeground = true } else { // If we are already in foreground just update the notification