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:
parent
dcc82608bd
commit
9c7e1d9fc2
2 changed files with 11 additions and 15 deletions
|
@ -35,20 +35,13 @@ import okio.source
|
|||
import org.oxycblt.auxio.list.Sort
|
||||
import org.oxycblt.auxio.music.*
|
||||
|
||||
/**
|
||||
* A [Keyer] implementation for [Music] data.
|
||||
*
|
||||
* @author Alexander Capehart (OxygenCobalt)
|
||||
*/
|
||||
class MusicKeyer : Keyer<Music> {
|
||||
// TODO: Include hashcode of child songs for parents
|
||||
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()
|
||||
class SongKeyer @Inject constructor() : Keyer<Song> {
|
||||
override fun key(data: Song, options: Options) =
|
||||
"${data.album.uid}${data.album.songs.hashCode()}"
|
||||
}
|
||||
|
||||
class ParentKeyer @Inject constructor() : Keyer<MusicParent> {
|
||||
override fun key(data: MusicParent, options: Options) = "${data.uid}${data.songs.hashCode()}"
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,8 @@ class ExtractorModule {
|
|||
@Provides
|
||||
fun imageLoader(
|
||||
@ApplicationContext context: Context,
|
||||
songKeyer: SongKeyer,
|
||||
parentKeyer: ParentKeyer,
|
||||
songFactory: AlbumCoverFetcher.SongFactory,
|
||||
albumFactory: AlbumCoverFetcher.AlbumFactory,
|
||||
artistFactory: ArtistImageFetcher.Factory,
|
||||
|
@ -44,7 +46,8 @@ class ExtractorModule {
|
|||
ImageLoader.Builder(context)
|
||||
.components {
|
||||
// Add fetchers for Music components to make them usable with ImageRequest
|
||||
add(MusicKeyer())
|
||||
add(songKeyer)
|
||||
add(parentKeyer)
|
||||
add(songFactory)
|
||||
add(albumFactory)
|
||||
add(artistFactory)
|
||||
|
|
Loading…
Reference in a new issue