Make Artist and Entry comparable (thus sortable)
This commit is contained in:
parent
aa1c0d8baa
commit
154662bec5
|
@ -9,8 +9,22 @@ data class Artist(
|
||||||
var coverArt: String? = null,
|
var coverArt: String? = null,
|
||||||
var albumCount: Long? = null,
|
var albumCount: Long? = null,
|
||||||
var closeness: Int = 0
|
var closeness: Int = 0
|
||||||
) : Serializable, GenericEntry() {
|
) : Serializable, GenericEntry(), Comparable<Artist> {
|
||||||
companion object {
|
companion object {
|
||||||
private const val serialVersionUID = -5790532593784846982L
|
private const val serialVersionUID = -5790532593784846982L
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun compareTo(other: Artist): Int {
|
||||||
|
when {
|
||||||
|
this.closeness == other.closeness -> {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
this.closeness > other.closeness -> {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ class MusicDirectory {
|
||||||
var bookmarkPosition: Int = 0,
|
var bookmarkPosition: Int = 0,
|
||||||
var userRating: Int? = null,
|
var userRating: Int? = null,
|
||||||
var averageRating: Float? = null
|
var averageRating: Float? = null
|
||||||
) : Serializable, GenericEntry() {
|
) : Serializable, GenericEntry(), Comparable<Entry> {
|
||||||
fun setDuration(duration: Long) {
|
fun setDuration(duration: Long) {
|
||||||
this.duration = duration.toInt()
|
this.duration = duration.toInt()
|
||||||
}
|
}
|
||||||
|
@ -74,5 +74,19 @@ class MusicDirectory {
|
||||||
companion object {
|
companion object {
|
||||||
private const val serialVersionUID = -3339106650010798108L
|
private const val serialVersionUID = -3339106650010798108L
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun compareTo(other: Entry): Int {
|
||||||
|
when {
|
||||||
|
this.closeness == other.closeness -> {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
this.closeness > other.closeness -> {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue