From 7b0e5027611d671bccc5f4ddd9b8eed5ffc10336 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Sun, 29 Jan 2023 19:34:32 -0700 Subject: [PATCH] music: fix broken equality Fix broken MusicParent equality that failed to properly compare types. --- .../oxycblt/auxio/list/selection/SelectionViewModel.kt | 1 + app/src/main/java/org/oxycblt/auxio/music/RealMusic.kt | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/list/selection/SelectionViewModel.kt b/app/src/main/java/org/oxycblt/auxio/list/selection/SelectionViewModel.kt index b827a4ee3..882ae11b4 100644 --- a/app/src/main/java/org/oxycblt/auxio/list/selection/SelectionViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/list/selection/SelectionViewModel.kt @@ -22,6 +22,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import org.oxycblt.auxio.music.* import org.oxycblt.auxio.music.library.Library +import org.oxycblt.auxio.util.logD /** * A [ViewModel] that manages the current selection. diff --git a/app/src/main/java/org/oxycblt/auxio/music/RealMusic.kt b/app/src/main/java/org/oxycblt/auxio/music/RealMusic.kt index 0336a2b83..b42817152 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/RealMusic.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/RealMusic.kt @@ -319,7 +319,8 @@ class RealAlbum(val raw: Raw, override val songs: List) : Album { // Note: Append song contents to MusicParent equality so that Groups with // the same UID but different contents are not equal. override fun hashCode() = 31 * uid.hashCode() + songs.hashCode() - override fun equals(other: Any?) = other is Album && uid == other.uid && songs == other.songs + override fun equals(other: Any?) = + other is RealAlbum && uid == other.uid && songs == other.songs private val _artists = mutableListOf() override val artists: List @@ -455,7 +456,8 @@ class RealArtist constructor(private val raw: Raw, songAlbums: List) : Ar // Note: Append song contents to MusicParent equality so that Groups with // the same UID but different contents are not equal. override fun hashCode() = 31 * uid.hashCode() + songs.hashCode() - override fun equals(other: Any?) = other is Album && uid == other.uid && songs == other.songs + override fun equals(other: Any?) = + other is RealArtist && uid == other.uid && songs == other.songs override lateinit var genres: List override fun resolveGenreContents(context: Context) = resolveNames(context, genres) @@ -581,7 +583,8 @@ class RealGenre constructor(private val raw: Raw, override val songs: List()