musikr: fix equality issues

This commit is contained in:
Alexander Capehart
2025-01-06 11:23:55 -07:00
parent 1fb6097b9d
commit bbc4db156e
7 changed files with 38 additions and 26 deletions
@@ -43,6 +43,10 @@ interface Cover {
}
class CoverCollection private constructor(val covers: List<Cover>) {
override fun hashCode() = covers.hashCode()
override fun equals(other: Any?) = other is CoverCollection && covers == other.covers
companion object {
fun from(covers: Collection<Cover>) =
CoverCollection(
@@ -57,7 +57,8 @@ interface FileCover : Cover {
suspend fun fd(): ParcelFileDescriptor?
}
private class FileCoverImpl(override val id: String, private val appFile: AppFile) : FileCover {
private data class FileCoverImpl(override val id: String, private val appFile: AppFile) :
FileCover {
override suspend fun fd() = appFile.fd()
override suspend fun open() = appFile.open()
@@ -96,7 +96,7 @@ private class AppFilesImpl(private val dir: File) : AppFiles {
}
}
private class AppFileImpl(private val file: File) : AppFile {
private data class AppFileImpl(private val file: File) : AppFile {
override suspend fun fd() =
withContext(Dispatchers.IO) {
try {
@@ -29,7 +29,7 @@ import org.oxycblt.musikr.util.update
internal interface AlbumCore {
val preAlbum: PreAlbum
val songs: List<Song>
val songs: Set<Song>
fun resolveArtists(): List<Artist>
}
@@ -39,7 +39,7 @@ internal interface AlbumCore {
*
* @author Alexander Capehart (OxygenCobalt)
*/
internal class AlbumImpl(private val core: AlbumCore) : Album {
class AlbumImpl internal constructor(private val core: AlbumCore) : Album {
private val preAlbum = core.preAlbum
override val uid =
@@ -73,4 +73,6 @@ internal class AlbumImpl(private val core: AlbumCore) : Album {
other is AlbumImpl && uid == other.uid && preAlbum == other.preAlbum && songs == other.songs
override fun toString() = "Album(uid=$uid, name=$name)"
fun a(other: AlbumImpl) = uid == other.uid
}
@@ -87,7 +87,7 @@ private class LibraryFactoryImpl() : LibraryFactory {
private class AlbumVertexCore(private val vertex: AlbumVertex) : AlbumCore {
override val preAlbum = vertex.preAlbum
override val songs = vertex.songVertices.map { SongImpl(SongVertexCore(it)) }
override val songs = vertex.songVertices.mapTo(mutableSetOf()) { it.tag as Song }
override fun resolveArtists() = vertex.artistVertices.map { it.tag as Artist }
}