[Glide] Added placeholder images for song, album & artist

main
Prathamesh More 2021-12-02 17:04:49 +05:30
parent 652a79f14e
commit e02e99ed02
3 changed files with 19 additions and 9 deletions

View File

@ -33,10 +33,10 @@ import java.io.File
@GlideExtension
object RetroGlideExtension {
private const val DEFAULT_ERROR_ARTIST_IMAGE =
private const val DEFAULT_ARTIST_IMAGE =
R.drawable.default_artist_art
private const val DEFAULT_ERROR_SONG_IMAGE: Int = R.drawable.default_audio_art
private const val DEFAULT_ERROR_ALBUM_IMAGE = R.drawable.default_album_art
private const val DEFAULT_SONG_IMAGE: Int = R.drawable.default_audio_art
private const val DEFAULT_ALBUM_IMAGE = R.drawable.default_album_art
private const val DEFAULT_ERROR_IMAGE_BANNER = R.drawable.material_design_default
private val DEFAULT_DISK_CACHE_STRATEGY_ARTIST = DiskCacheStrategy.RESOURCE
@ -99,7 +99,8 @@ object RetroGlideExtension {
return baseRequestOptions
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY_ARTIST)
.priority(Priority.LOW)
.error(DEFAULT_ERROR_ARTIST_IMAGE)
.error(DEFAULT_ARTIST_IMAGE)
.placeholder(DEFAULT_ARTIST_IMAGE)
.signature(createSignature(artist))
}
@ -110,7 +111,8 @@ object RetroGlideExtension {
song: Song
): BaseRequestOptions<*> {
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
.error(DEFAULT_ERROR_SONG_IMAGE)
.error(DEFAULT_SONG_IMAGE)
.placeholder(DEFAULT_SONG_IMAGE)
.signature(createSignature(song))
}
@ -121,7 +123,8 @@ object RetroGlideExtension {
song: Song
): BaseRequestOptions<*> {
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
.error(DEFAULT_ERROR_ALBUM_IMAGE)
.error(DEFAULT_ALBUM_IMAGE)
.placeholder(DEFAULT_ALBUM_IMAGE)
.signature(createSignature(song))
}
@ -154,7 +157,7 @@ object RetroGlideExtension {
baseRequestOptions: BaseRequestOptions<*>
): BaseRequestOptions<*> {
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
.error(DEFAULT_ERROR_ALBUM_IMAGE)
.error(DEFAULT_ALBUM_IMAGE)
}
private fun createSignature(song: Song): Key {

View File

@ -33,8 +33,7 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
val colors = MediaNotificationProcessor(App.getContext(), errorDrawable)
onColorReady(colors)
onColorReady(MediaNotificationProcessor.errorColor(App.getContext()))
}
override fun onResourceReady(

View File

@ -473,4 +473,12 @@ public class MediaNotificationProcessor {
public interface OnPaletteLoadedListener {
void onPaletteLoaded(MediaNotificationProcessor mediaNotificationProcessor);
}
public static MediaNotificationProcessor errorColor(Context context) {
MediaNotificationProcessor errorColors = new MediaNotificationProcessor(context);
errorColors.backgroundColor = 0x15724528;
errorColors.primaryTextColor = 0x6974059;
errorColors.secondaryTextColor = 0x8684677;
return errorColors;
}
}