Browse Source

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

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
4cf77404a1
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 4
      app/src/main/java/com/github/apognu/otter/repositories/TracksRepository.kt
  2. 1
      app/src/main/java/com/github/apognu/otter/utils/Models.kt

4
app/src/main/java/com/github/apognu/otter/repositories/TracksRepository.kt

@ -13,7 +13,7 @@ import java.io.BufferedReader @@ -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 @@ -56,6 +56,6 @@ class TracksRepository(override val context: Context?, albumId: Int) : Repositor
}
track
}.sortedBy { it.position }
}.sortedWith(compareBy({ it.disc_number }, { it.position }))
}
}

1
app/src/main/java/com/github/apognu/otter/utils/Models.kt

@ -101,6 +101,7 @@ data class Track( @@ -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,

Loading…
Cancel
Save