Fixed unshuffled songs when restoring the playing queue
This commit is contained in:
parent
ead8520333
commit
0c4cabc755
4 changed files with 10 additions and 5 deletions
|
@ -53,7 +53,7 @@ class ErrorActivity : AppCompatActivity() {
|
||||||
)
|
)
|
||||||
.setNeutralButton(
|
.setNeutralButton(
|
||||||
R.string.customactivityoncrash_error_activity_error_details_share
|
R.string.customactivityoncrash_error_activity_error_details_share
|
||||||
) { dialog, which ->
|
) { _, _ ->
|
||||||
|
|
||||||
val bugReport = createFile(
|
val bugReport = createFile(
|
||||||
context = this,
|
context = this,
|
||||||
|
|
|
@ -25,7 +25,6 @@ import code.name.monkey.retromusic.extensions.surfaceColor
|
||||||
import code.name.monkey.retromusic.fragments.GridStyle
|
import code.name.monkey.retromusic.fragments.GridStyle
|
||||||
import code.name.monkey.retromusic.fragments.ReloadType
|
import code.name.monkey.retromusic.fragments.ReloadType
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
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.helper.SortOrder.SongSortOrder
|
||||||
import code.name.monkey.retromusic.interfaces.ICabCallback
|
import code.name.monkey.retromusic.interfaces.ICabCallback
|
||||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||||
|
@ -66,7 +65,7 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
||||||
get() = true
|
get() = true
|
||||||
|
|
||||||
override fun onShuffleClicked() {
|
override fun onShuffleClicked() {
|
||||||
libraryViewModel.getSongs().value?.let { MusicPlayerRemote.openAndShuffleQueue(it, true) }
|
libraryViewModel.shuffleSongs()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createLayoutManager(): GridLayoutManager {
|
override fun createLayoutManager(): GridLayoutManager {
|
||||||
|
|
|
@ -43,6 +43,8 @@ interface SongRepository {
|
||||||
|
|
||||||
fun songs(cursor: Cursor?): List<Song>
|
fun songs(cursor: Cursor?): List<Song>
|
||||||
|
|
||||||
|
fun sortedSongs(cursor: Cursor?): List<Song>
|
||||||
|
|
||||||
fun songs(query: String): List<Song>
|
fun songs(query: String): List<Song>
|
||||||
|
|
||||||
fun songsByFilePath(filePath: String, ignoreBlacklist: Boolean = false): List<Song>
|
fun songsByFilePath(filePath: String, ignoreBlacklist: Boolean = false): List<Song>
|
||||||
|
@ -57,7 +59,7 @@ interface SongRepository {
|
||||||
class RealSongRepository(private val context: Context) : SongRepository {
|
class RealSongRepository(private val context: Context) : SongRepository {
|
||||||
|
|
||||||
override fun songs(): List<Song> {
|
override fun songs(): List<Song> {
|
||||||
return songs(makeSongCursor(null, null))
|
return sortedSongs(makeSongCursor(null, null))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun songs(cursor: Cursor?): List<Song> {
|
override fun songs(cursor: Cursor?): List<Song> {
|
||||||
|
@ -68,7 +70,12 @@ class RealSongRepository(private val context: Context) : SongRepository {
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
|
return songs
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sortedSongs(cursor: Cursor?): List<Song> {
|
||||||
val collator = Collator.getInstance()
|
val collator = Collator.getInstance()
|
||||||
|
val songs = songs(cursor)
|
||||||
return when (PreferenceUtil.songSortOrder) {
|
return when (PreferenceUtil.songSortOrder) {
|
||||||
SortOrder.SongSortOrder.SONG_A_Z -> {
|
SortOrder.SongSortOrder.SONG_A_Z -> {
|
||||||
songs.sortedWith{ s1, s2 -> collator.compare(s1.title, s2.title) }
|
songs.sortedWith{ s1, s2 -> collator.compare(s1.title, s2.title) }
|
||||||
|
|
|
@ -181,7 +181,6 @@ class PlayingNotificationImpl24(
|
||||||
onUpdate()
|
onUpdate()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
updateFavorite(song, onUpdate)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildPlayAction(isPlaying: Boolean): NotificationCompat.Action {
|
private fun buildPlayAction(isPlaying: Boolean): NotificationCompat.Action {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue