image: differentiate different parent songs

Differentiate parents based on their song composition.

This way, it's less likely for an artist/genre/playlist image to get
"stuck" after a library change.
This commit is contained in:
Alexander Capehart 2023-05-17 11:12:26 -06:00
parent dcc82608bd
commit 9c7e1d9fc2
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 11 additions and 15 deletions

View file

@ -35,20 +35,13 @@ import okio.source
import org.oxycblt.auxio.list.Sort import org.oxycblt.auxio.list.Sort
import org.oxycblt.auxio.music.* import org.oxycblt.auxio.music.*
/** class SongKeyer @Inject constructor() : Keyer<Song> {
* A [Keyer] implementation for [Music] data. override fun key(data: Song, options: Options) =
* "${data.album.uid}${data.album.songs.hashCode()}"
* @author Alexander Capehart (OxygenCobalt) }
*/
class MusicKeyer : Keyer<Music> { class ParentKeyer @Inject constructor() : Keyer<MusicParent> {
// TODO: Include hashcode of child songs for parents override fun key(data: MusicParent, options: Options) = "${data.uid}${data.songs.hashCode()}"
override fun key(data: Music, options: Options) =
if (data is Song) {
// Group up song covers with album covers for better caching
data.album.uid.toString()
} else {
data.uid.toString()
}
} }
/** /**

View file

@ -35,6 +35,8 @@ class ExtractorModule {
@Provides @Provides
fun imageLoader( fun imageLoader(
@ApplicationContext context: Context, @ApplicationContext context: Context,
songKeyer: SongKeyer,
parentKeyer: ParentKeyer,
songFactory: AlbumCoverFetcher.SongFactory, songFactory: AlbumCoverFetcher.SongFactory,
albumFactory: AlbumCoverFetcher.AlbumFactory, albumFactory: AlbumCoverFetcher.AlbumFactory,
artistFactory: ArtistImageFetcher.Factory, artistFactory: ArtistImageFetcher.Factory,
@ -44,7 +46,8 @@ class ExtractorModule {
ImageLoader.Builder(context) ImageLoader.Builder(context)
.components { .components {
// Add fetchers for Music components to make them usable with ImageRequest // Add fetchers for Music components to make them usable with ImageRequest
add(MusicKeyer()) add(songKeyer)
add(parentKeyer)
add(songFactory) add(songFactory)
add(albumFactory) add(albumFactory)
add(artistFactory) add(artistFactory)