diff --git a/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/Artist.kt b/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/Artist.kt index 466d4832..b7112e2f 100644 --- a/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/Artist.kt +++ b/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/Artist.kt @@ -9,8 +9,22 @@ data class Artist( var coverArt: String? = null, var albumCount: Long? = null, var closeness: Int = 0 -) : Serializable, GenericEntry() { +) : Serializable, GenericEntry(), Comparable { companion object { 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 + } + } + } } diff --git a/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/MusicDirectory.kt b/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/MusicDirectory.kt index 0a5295dd..cdd035a5 100644 --- a/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/MusicDirectory.kt +++ b/core/domain/src/main/kotlin/org/moire/ultrasonic/domain/MusicDirectory.kt @@ -66,7 +66,7 @@ class MusicDirectory { var bookmarkPosition: Int = 0, var userRating: Int? = null, var averageRating: Float? = null - ) : Serializable, GenericEntry() { + ) : Serializable, GenericEntry(), Comparable { fun setDuration(duration: Long) { this.duration = duration.toInt() } @@ -74,5 +74,19 @@ class MusicDirectory { companion object { 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 + } + } + } } }