musikr: re-connect cover to model

This commit is contained in:
Alexander Capehart 2024-12-11 17:16:34 -07:00
parent cf69b27134
commit 0ce3a11f82
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
9 changed files with 12 additions and 12 deletions

View file

@ -374,7 +374,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
fun bind(songs: List<Song>, desc: String, @DrawableRes errorRes: Int) =
bindImpl(Cover.multi(songs), desc, errorRes)
private fun bindImpl(cover: Cover, desc: String, @DrawableRes errorRes: Int) {
private fun bindImpl(cover: Cover?, desc: String, @DrawableRes errorRes: Int) {
val request =
ImageRequest.Builder(context)
.data(cover)

View file

@ -265,7 +265,7 @@ interface Song : Music {
/** The date the audio file was added to the device, as a unix epoch timestamp. */
val dateAdded: Long
/** Useful information to quickly obtain the album cover. */
val cover: Cover.Single
val cover: Cover.Single?
/**
* The parent [Album]. If the metadata did not specify an album, it's parent directory is used
* instead.

View file

@ -34,7 +34,7 @@ interface Cache {
}
}
data class CachedSong(val parsedTags: ParsedTags, val cover: Cover?)
data class CachedSong(val parsedTags: ParsedTags, val cover: Cover.Single?)
private class FullCache(private val cacheInfoDao: CacheInfoDao) : Cache {
override suspend fun read(file: DeviceFile) =

View file

@ -88,7 +88,7 @@ internal data class CachedInfo(
val albumArtistNames: List<String>,
val albumArtistSortNames: List<String>,
val genreNames: List<String>,
val cover: Cover? = null
val cover: Cover.Single? = null
) {
fun intoCachedSong() =
CachedSong(
@ -128,7 +128,7 @@ internal data class CachedInfo(
@TypeConverter fun toDate(string: String?) = string?.let(Date::from)
@TypeConverter fun fromCover(cover: Cover?) = cover?.key
@TypeConverter fun fromCover(cover: Cover.Single?) = cover?.key
@TypeConverter fun toCover(key: String?) = key?.let { Cover.Single(it) }
}

View file

@ -41,7 +41,7 @@ sealed interface Cover {
private fun order(songs: Collection<Song>) =
FALLBACK_SORT.songs(songs)
.map { it.cover }
.mapNotNull { it.cover }
.groupBy { it.key }
.entries
.sortedByDescending { it.value.size }

View file

@ -22,7 +22,6 @@ import org.oxycblt.musikr.Album
import org.oxycblt.musikr.Artist
import org.oxycblt.musikr.Genre
import org.oxycblt.musikr.Song
import org.oxycblt.musikr.cover.Cover
import org.oxycblt.musikr.tag.interpret.PreSong
interface SongCore {
@ -56,7 +55,7 @@ class SongImpl(private val handle: SongCore) : Song {
override val replayGainAdjustment = preSong.replayGainAdjustment
override val lastModified = preSong.lastModified
override val dateAdded = preSong.dateAdded
override val cover = Cover.single("")
override val cover = preSong.cover
override val album: Album
get() = handle.resolveAlbum()

View file

@ -96,5 +96,6 @@ constructor(
}
sealed interface ExtractedMusic {
data class Song(val file: DeviceFile, val tags: ParsedTags, val cover: Cover?) : ExtractedMusic
data class Song(val file: DeviceFile, val tags: ParsedTags, val cover: Cover.Single?) :
ExtractedMusic
}

View file

@ -48,7 +48,7 @@ data class PreSong(
val replayGainAdjustment: ReplayGainAdjustment,
val lastModified: Long,
val dateAdded: Long,
val cover: Cover?,
val cover: Cover.Single?,
val preAlbum: PreAlbum,
val preArtists: List<PreArtist>,
val preGenres: List<PreGenre>

View file

@ -36,7 +36,7 @@ interface TagInterpreter {
fun interpret(
file: DeviceFile,
parsedTags: ParsedTags,
cover: Cover?,
cover: Cover.Single?,
interpretation: Interpretation
): PreSong
}
@ -45,7 +45,7 @@ class TagInterpreterImpl @Inject constructor() : TagInterpreter {
override fun interpret(
file: DeviceFile,
parsedTags: ParsedTags,
cover: Cover?,
cover: Cover.Single?,
interpretation: Interpretation
): PreSong {
val individualPreArtists =