playback: fix index bug
Fix some index bugs by using inc/dec instead of ++/--.
This commit is contained in:
parent
e451bc9859
commit
ac6a471318
2 changed files with 6 additions and 6 deletions
|
@ -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<Song>) {
|
||||
mutableQueue.addAll(++index, songs)
|
||||
mutableQueue.addAll(index.inc(), songs)
|
||||
notifyQueueChanged()
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue