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
|
// Increment the index, if it cannot be incremented any further, then
|
||||||
// repeat and pause/resume playback depending on the setting
|
// repeat and pause/resume playback depending on the setting
|
||||||
if (index < mutableQueue.lastIndex) {
|
if (index < mutableQueue.lastIndex) {
|
||||||
goto(++index, true)
|
goto(index.inc(), true)
|
||||||
} else {
|
} else {
|
||||||
goto(0, repeatMode == RepeatMode.ALL)
|
goto(0, repeatMode == RepeatMode.ALL)
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ class PlaybackStateManager private constructor() {
|
||||||
rewind()
|
rewind()
|
||||||
isPlaying = true
|
isPlaying = true
|
||||||
} else {
|
} 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. */
|
/** Add a [song] to the top of the queue. */
|
||||||
fun playNext(song: Song) {
|
fun playNext(song: Song) {
|
||||||
mutableQueue.add(++index, song)
|
mutableQueue.add(index.inc(), song)
|
||||||
notifyQueueChanged()
|
notifyQueueChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add a list of [songs] to the top of the queue. */
|
/** Add a list of [songs] to the top of the queue. */
|
||||||
fun playNext(songs: List<Song>) {
|
fun playNext(songs: List<Song>) {
|
||||||
mutableQueue.addAll(++index, songs)
|
mutableQueue.addAll(index.inc(), songs)
|
||||||
notifyQueueChanged()
|
notifyQueueChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,8 @@ import org.oxycblt.auxio.widgets.WidgetProvider
|
||||||
* therefore there's no need to bind to it to deliver commands.
|
* therefore there's no need to bind to it to deliver commands.
|
||||||
* @author OxygenCobalt
|
* @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 :
|
class PlaybackService :
|
||||||
Service(), Player.Listener, PlaybackStateManager.Callback, SettingsManager.Callback {
|
Service(), Player.Listener, PlaybackStateManager.Callback, SettingsManager.Callback {
|
||||||
|
@ -374,7 +375,6 @@ class PlaybackService :
|
||||||
|
|
||||||
if (!isForeground) {
|
if (!isForeground) {
|
||||||
startForeground(IntegerTable.NOTIFICATION_CODE, notificationComponent.build())
|
startForeground(IntegerTable.NOTIFICATION_CODE, notificationComponent.build())
|
||||||
|
|
||||||
isForeground = true
|
isForeground = true
|
||||||
} else {
|
} else {
|
||||||
// If we are already in foreground just update the notification
|
// If we are already in foreground just update the notification
|
||||||
|
|
Loading…
Reference in a new issue