Fix issue with song display

Fix a bug where playing a song with remember shuffle on would cause the song display to look wrong.
This commit is contained in:
OxygenCobalt 2021-01-11 12:17:39 -07:00
parent d507b77d32
commit 4f8ddb793f
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -154,6 +154,9 @@ class PlaybackStateManager private constructor() {
fun playSong(song: Song, mode: PlaybackMode) { fun playSong(song: Song, mode: PlaybackMode) {
logD("Updating song to ${song.name} and mode to $mode") logD("Updating song to ${song.name} and mode to $mode")
// Song is updated immediately, as its reference is needed for the queue calculations
updatePlayback(song)
val shouldShuffle = settingsManager.keepShuffle && mIsShuffling val shouldShuffle = settingsManager.keepShuffle && mIsShuffling
when (mode) { when (mode) {
@ -161,7 +164,7 @@ class PlaybackStateManager private constructor() {
mParent = null mParent = null
mQueue = if (shouldShuffle) { mQueue = if (shouldShuffle) {
genShuffle(musicStore.songs.toMutableList(), false) genShuffle(musicStore.songs.toMutableList(), true)
} else { } else {
musicStore.songs.toMutableList() musicStore.songs.toMutableList()
} }
@ -171,7 +174,7 @@ class PlaybackStateManager private constructor() {
if (song.genre != null) { if (song.genre != null) {
mParent = song.genre mParent = song.genre
mQueue = if (shouldShuffle) { mQueue = if (shouldShuffle) {
genShuffle(song.genre!!.songs.toMutableList(), false) genShuffle(song.genre!!.songs.toMutableList(), true)
} else { } else {
orderSongsInGenre(song.genre!!) orderSongsInGenre(song.genre!!)
} }
@ -185,7 +188,7 @@ class PlaybackStateManager private constructor() {
PlaybackMode.IN_ARTIST -> { PlaybackMode.IN_ARTIST -> {
mParent = song.album.artist mParent = song.album.artist
mQueue = if (shouldShuffle) { mQueue = if (shouldShuffle) {
genShuffle(song.album.artist.songs.toMutableList(), false) genShuffle(song.album.artist.songs.toMutableList(), true)
} else { } else {
orderSongsInArtist(song.album.artist) orderSongsInArtist(song.album.artist)
} }
@ -194,7 +197,7 @@ class PlaybackStateManager private constructor() {
PlaybackMode.IN_ALBUM -> { PlaybackMode.IN_ALBUM -> {
mParent = song.album mParent = song.album
mQueue = if (shouldShuffle) { mQueue = if (shouldShuffle) {
genShuffle(song.album.songs.toMutableList(), false) genShuffle(song.album.songs.toMutableList(), true)
} else { } else {
orderSongsInAlbum(song.album) orderSongsInAlbum(song.album)
} }
@ -205,7 +208,6 @@ class PlaybackStateManager private constructor() {
mIsShuffling = shouldShuffle mIsShuffling = shouldShuffle
resetLoopMode() resetLoopMode()
updatePlayback(song)
mIndex = mQueue.indexOf(song) mIndex = mQueue.indexOf(song)
} }