musikr: re-connect cover to model
This commit is contained in:
parent
cf69b27134
commit
0ce3a11f82
9 changed files with 12 additions and 12 deletions
|
@ -374,7 +374,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
fun bind(songs: List<Song>, desc: String, @DrawableRes errorRes: Int) =
|
fun bind(songs: List<Song>, desc: String, @DrawableRes errorRes: Int) =
|
||||||
bindImpl(Cover.multi(songs), desc, errorRes)
|
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 =
|
val request =
|
||||||
ImageRequest.Builder(context)
|
ImageRequest.Builder(context)
|
||||||
.data(cover)
|
.data(cover)
|
||||||
|
|
|
@ -265,7 +265,7 @@ interface Song : Music {
|
||||||
/** The date the audio file was added to the device, as a unix epoch timestamp. */
|
/** The date the audio file was added to the device, as a unix epoch timestamp. */
|
||||||
val dateAdded: Long
|
val dateAdded: Long
|
||||||
/** Useful information to quickly obtain the album cover. */
|
/** 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
|
* The parent [Album]. If the metadata did not specify an album, it's parent directory is used
|
||||||
* instead.
|
* instead.
|
||||||
|
|
|
@ -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 {
|
private class FullCache(private val cacheInfoDao: CacheInfoDao) : Cache {
|
||||||
override suspend fun read(file: DeviceFile) =
|
override suspend fun read(file: DeviceFile) =
|
||||||
|
|
|
@ -88,7 +88,7 @@ internal data class CachedInfo(
|
||||||
val albumArtistNames: List<String>,
|
val albumArtistNames: List<String>,
|
||||||
val albumArtistSortNames: List<String>,
|
val albumArtistSortNames: List<String>,
|
||||||
val genreNames: List<String>,
|
val genreNames: List<String>,
|
||||||
val cover: Cover? = null
|
val cover: Cover.Single? = null
|
||||||
) {
|
) {
|
||||||
fun intoCachedSong() =
|
fun intoCachedSong() =
|
||||||
CachedSong(
|
CachedSong(
|
||||||
|
@ -128,7 +128,7 @@ internal data class CachedInfo(
|
||||||
|
|
||||||
@TypeConverter fun toDate(string: String?) = string?.let(Date::from)
|
@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) }
|
@TypeConverter fun toCover(key: String?) = key?.let { Cover.Single(it) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ sealed interface Cover {
|
||||||
|
|
||||||
private fun order(songs: Collection<Song>) =
|
private fun order(songs: Collection<Song>) =
|
||||||
FALLBACK_SORT.songs(songs)
|
FALLBACK_SORT.songs(songs)
|
||||||
.map { it.cover }
|
.mapNotNull { it.cover }
|
||||||
.groupBy { it.key }
|
.groupBy { it.key }
|
||||||
.entries
|
.entries
|
||||||
.sortedByDescending { it.value.size }
|
.sortedByDescending { it.value.size }
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.oxycblt.musikr.Album
|
||||||
import org.oxycblt.musikr.Artist
|
import org.oxycblt.musikr.Artist
|
||||||
import org.oxycblt.musikr.Genre
|
import org.oxycblt.musikr.Genre
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
import org.oxycblt.musikr.cover.Cover
|
|
||||||
import org.oxycblt.musikr.tag.interpret.PreSong
|
import org.oxycblt.musikr.tag.interpret.PreSong
|
||||||
|
|
||||||
interface SongCore {
|
interface SongCore {
|
||||||
|
@ -56,7 +55,7 @@ class SongImpl(private val handle: SongCore) : Song {
|
||||||
override val replayGainAdjustment = preSong.replayGainAdjustment
|
override val replayGainAdjustment = preSong.replayGainAdjustment
|
||||||
override val lastModified = preSong.lastModified
|
override val lastModified = preSong.lastModified
|
||||||
override val dateAdded = preSong.dateAdded
|
override val dateAdded = preSong.dateAdded
|
||||||
override val cover = Cover.single("")
|
override val cover = preSong.cover
|
||||||
override val album: Album
|
override val album: Album
|
||||||
get() = handle.resolveAlbum()
|
get() = handle.resolveAlbum()
|
||||||
|
|
||||||
|
|
|
@ -96,5 +96,6 @@ constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed interface ExtractedMusic {
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ data class PreSong(
|
||||||
val replayGainAdjustment: ReplayGainAdjustment,
|
val replayGainAdjustment: ReplayGainAdjustment,
|
||||||
val lastModified: Long,
|
val lastModified: Long,
|
||||||
val dateAdded: Long,
|
val dateAdded: Long,
|
||||||
val cover: Cover?,
|
val cover: Cover.Single?,
|
||||||
val preAlbum: PreAlbum,
|
val preAlbum: PreAlbum,
|
||||||
val preArtists: List<PreArtist>,
|
val preArtists: List<PreArtist>,
|
||||||
val preGenres: List<PreGenre>
|
val preGenres: List<PreGenre>
|
||||||
|
|
|
@ -36,7 +36,7 @@ interface TagInterpreter {
|
||||||
fun interpret(
|
fun interpret(
|
||||||
file: DeviceFile,
|
file: DeviceFile,
|
||||||
parsedTags: ParsedTags,
|
parsedTags: ParsedTags,
|
||||||
cover: Cover?,
|
cover: Cover.Single?,
|
||||||
interpretation: Interpretation
|
interpretation: Interpretation
|
||||||
): PreSong
|
): PreSong
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class TagInterpreterImpl @Inject constructor() : TagInterpreter {
|
||||||
override fun interpret(
|
override fun interpret(
|
||||||
file: DeviceFile,
|
file: DeviceFile,
|
||||||
parsedTags: ParsedTags,
|
parsedTags: ParsedTags,
|
||||||
cover: Cover?,
|
cover: Cover.Single?,
|
||||||
interpretation: Interpretation
|
interpretation: Interpretation
|
||||||
): PreSong {
|
): PreSong {
|
||||||
val individualPreArtists =
|
val individualPreArtists =
|
||||||
|
|
Loading…
Reference in a new issue