music: add equals impl to library
Now that Library is no longer a data class, it needs to have an implementation of equals. This caused all reloads to be interpreted as new libraries, even when they were not.
This commit is contained in:
parent
f4aee4532b
commit
5eab83ba4d
2 changed files with 16 additions and 0 deletions
|
@ -100,6 +100,21 @@ private class LibraryImpl(rawSongs: List<RawSong>, settings: MusicSettings) : Li
|
||||||
genres.forEach { put(it.uid, it.finalize()) }
|
genres.forEach { put(it.uid, it.finalize()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?) =
|
||||||
|
other is Library &&
|
||||||
|
other.songs == songs &&
|
||||||
|
other.albums == albums &&
|
||||||
|
other.artists == artists &&
|
||||||
|
other.genres == genres
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var hashCode = songs.hashCode()
|
||||||
|
hashCode = hashCode * 31 + albums.hashCode()
|
||||||
|
hashCode = hashCode * 31 + artists.hashCode()
|
||||||
|
hashCode = hashCode * 31 + genres.hashCode()
|
||||||
|
return hashCode
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a [Music] item [T] in the library by it's [Music.UID].
|
* Finds a [Music] item [T] in the library by it's [Music.UID].
|
||||||
* @param uid The [Music.UID] to search for.
|
* @param uid The [Music.UID] to search for.
|
||||||
|
|
|
@ -85,6 +85,7 @@ interface Settings<L> {
|
||||||
sharedPreferences: SharedPreferences,
|
sharedPreferences: SharedPreferences,
|
||||||
key: String
|
key: String
|
||||||
) {
|
) {
|
||||||
|
// FIXME: Settings initialization firing the listener.
|
||||||
onSettingChanged(key, unlikelyToBeNull(listener))
|
onSettingChanged(key, unlikelyToBeNull(listener))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue