Fixed Top/Recent Artists/Albums order

This commit is contained in:
Prathamesh More 2022-05-17 10:28:27 +05:30
parent 6779eb0e2b
commit 197e7ff085
3 changed files with 5 additions and 3 deletions

View file

@ -72,9 +72,11 @@ class RealAlbumRepository(private val songRepository: RealSongRepository) :
// We don't need sorted list of songs (with sortAlbumSongs()) // We don't need sorted list of songs (with sortAlbumSongs())
// cuz we are just displaying Albums(Cover Arts) anyway and not songs // cuz we are just displaying Albums(Cover Arts) anyway and not songs
fun splitIntoAlbums( fun splitIntoAlbums(
songs: List<Song> songs: List<Song>,
sorted: Boolean = true
): List<Album> { ): List<Album> {
val grouped = songs.groupBy { it.albumId }.map { Album(it.key, it.value) } val grouped = songs.groupBy { it.albumId }.map { Album(it.key, it.value) }
if (!sorted) return grouped
val collator = Collator.getInstance() val collator = Collator.getInstance()
return when (PreferenceUtil.albumSortOrder) { return when (PreferenceUtil.albumSortOrder) {
SortOrder.AlbumSortOrder.ALBUM_A_Z -> { SortOrder.AlbumSortOrder.ALBUM_A_Z -> {

View file

@ -42,7 +42,7 @@ class RealLastAddedRepository(
} }
override fun recentAlbums(): List<Album> { override fun recentAlbums(): List<Album> {
return albumRepository.splitIntoAlbums(recentSongs()) return albumRepository.splitIntoAlbums(recentSongs(), sorted = false)
} }
override fun recentArtists(): List<Artist> { override fun recentArtists(): List<Artist> {

View file

@ -81,7 +81,7 @@ class RealTopPlayedRepository(
} }
override fun topAlbums(): List<Album> { override fun topAlbums(): List<Album> {
return albumRepository.splitIntoAlbums(topTracks()) return albumRepository.splitIntoAlbums(topTracks(), sorted = false)
} }
override fun topArtists(): List<Artist> { override fun topArtists(): List<Artist> {