Fixed unshuffled songs when restoring the playing queue

This commit is contained in:
Prathamesh More 2022-03-27 14:37:42 +05:30
parent ead8520333
commit 0c4cabc755
4 changed files with 10 additions and 5 deletions

View file

@ -53,7 +53,7 @@ class ErrorActivity : AppCompatActivity() {
)
.setNeutralButton(
R.string.customactivityoncrash_error_activity_error_details_share
) { dialog, which ->
) { _, _ ->
val bugReport = createFile(
context = this,

View file

@ -25,7 +25,6 @@ import code.name.monkey.retromusic.extensions.surfaceColor
import code.name.monkey.retromusic.fragments.GridStyle
import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder
import code.name.monkey.retromusic.interfaces.ICabCallback
import code.name.monkey.retromusic.interfaces.ICabHolder
@ -66,7 +65,7 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
get() = true
override fun onShuffleClicked() {
libraryViewModel.getSongs().value?.let { MusicPlayerRemote.openAndShuffleQueue(it, true) }
libraryViewModel.shuffleSongs()
}
override fun createLayoutManager(): GridLayoutManager {

View file

@ -43,6 +43,8 @@ interface SongRepository {
fun songs(cursor: Cursor?): List<Song>
fun sortedSongs(cursor: Cursor?): List<Song>
fun songs(query: String): List<Song>
fun songsByFilePath(filePath: String, ignoreBlacklist: Boolean = false): List<Song>
@ -57,7 +59,7 @@ interface SongRepository {
class RealSongRepository(private val context: Context) : SongRepository {
override fun songs(): List<Song> {
return songs(makeSongCursor(null, null))
return sortedSongs(makeSongCursor(null, null))
}
override fun songs(cursor: Cursor?): List<Song> {
@ -68,7 +70,12 @@ class RealSongRepository(private val context: Context) : SongRepository {
} while (cursor.moveToNext())
}
cursor?.close()
return songs
}
override fun sortedSongs(cursor: Cursor?): List<Song> {
val collator = Collator.getInstance()
val songs = songs(cursor)
return when (PreferenceUtil.songSortOrder) {
SortOrder.SongSortOrder.SONG_A_Z -> {
songs.sortedWith{ s1, s2 -> collator.compare(s1.title, s2.title) }

View file

@ -181,7 +181,6 @@ class PlayingNotificationImpl24(
onUpdate()
}
})
updateFavorite(song, onUpdate)
}
private fun buildPlayAction(isPlaying: Boolean): NotificationCompat.Action {