#73: fix track sorting order by fixing a mistake and taking disc_number into consideration.

This commit is contained in:
Antoine POPINEAU 2020-09-01 18:25:10 +02:00
parent 9beb5e6641
commit 4cf77404a1
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
2 changed files with 3 additions and 2 deletions

View File

@ -13,7 +13,7 @@ import java.io.BufferedReader
class TracksRepository(override val context: Context?, albumId: Int) : Repository<Track, TracksCache>() {
override val cacheId = "tracks-album-$albumId"
override val upstream = HttpUpstream<Track, OtterResponse<Track>>(HttpUpstream.Behavior.AtOnce, "/api/v1/tracks/?playable=true&album=$albumId", object : TypeToken<TracksResponse>() {}.type)
override val upstream = HttpUpstream<Track, OtterResponse<Track>>(HttpUpstream.Behavior.AtOnce, "/api/v1/tracks/?playable=true&album=$albumId&ordering=disc_number,position", object : TypeToken<TracksResponse>() {}.type)
override fun cache(data: List<Track>) = TracksCache(data)
override fun uncache(reader: BufferedReader) = gsonDeserializerOf(TracksCache::class.java).deserialize(reader)
@ -56,6 +56,6 @@ class TracksRepository(override val context: Context?, albumId: Int) : Repositor
}
track
}.sortedBy { it.position }
}.sortedWith(compareBy({ it.disc_number }, { it.position }))
}
}

View File

@ -101,6 +101,7 @@ data class Track(
val title: String,
val artist: Artist,
val album: Album?,
val disc_number: Int = 0,
val position: Int = 0,
val uploads: List<Upload> = listOf(),
val copyright: String? = null,