[Glide] Added placeholder images for song, album & artist
This commit is contained in:
parent
652a79f14e
commit
e02e99ed02
3 changed files with 19 additions and 9 deletions
|
@ -33,10 +33,10 @@ import java.io.File
|
||||||
@GlideExtension
|
@GlideExtension
|
||||||
object RetroGlideExtension {
|
object RetroGlideExtension {
|
||||||
|
|
||||||
private const val DEFAULT_ERROR_ARTIST_IMAGE =
|
private const val DEFAULT_ARTIST_IMAGE =
|
||||||
R.drawable.default_artist_art
|
R.drawable.default_artist_art
|
||||||
private const val DEFAULT_ERROR_SONG_IMAGE: Int = R.drawable.default_audio_art
|
private const val DEFAULT_SONG_IMAGE: Int = R.drawable.default_audio_art
|
||||||
private const val DEFAULT_ERROR_ALBUM_IMAGE = R.drawable.default_album_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 const val DEFAULT_ERROR_IMAGE_BANNER = R.drawable.material_design_default
|
||||||
|
|
||||||
private val DEFAULT_DISK_CACHE_STRATEGY_ARTIST = DiskCacheStrategy.RESOURCE
|
private val DEFAULT_DISK_CACHE_STRATEGY_ARTIST = DiskCacheStrategy.RESOURCE
|
||||||
|
@ -99,7 +99,8 @@ object RetroGlideExtension {
|
||||||
return baseRequestOptions
|
return baseRequestOptions
|
||||||
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY_ARTIST)
|
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY_ARTIST)
|
||||||
.priority(Priority.LOW)
|
.priority(Priority.LOW)
|
||||||
.error(DEFAULT_ERROR_ARTIST_IMAGE)
|
.error(DEFAULT_ARTIST_IMAGE)
|
||||||
|
.placeholder(DEFAULT_ARTIST_IMAGE)
|
||||||
.signature(createSignature(artist))
|
.signature(createSignature(artist))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +111,8 @@ object RetroGlideExtension {
|
||||||
song: Song
|
song: Song
|
||||||
): BaseRequestOptions<*> {
|
): BaseRequestOptions<*> {
|
||||||
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
||||||
.error(DEFAULT_ERROR_SONG_IMAGE)
|
.error(DEFAULT_SONG_IMAGE)
|
||||||
|
.placeholder(DEFAULT_SONG_IMAGE)
|
||||||
.signature(createSignature(song))
|
.signature(createSignature(song))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +123,8 @@ object RetroGlideExtension {
|
||||||
song: Song
|
song: Song
|
||||||
): BaseRequestOptions<*> {
|
): BaseRequestOptions<*> {
|
||||||
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
||||||
.error(DEFAULT_ERROR_ALBUM_IMAGE)
|
.error(DEFAULT_ALBUM_IMAGE)
|
||||||
|
.placeholder(DEFAULT_ALBUM_IMAGE)
|
||||||
.signature(createSignature(song))
|
.signature(createSignature(song))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +157,7 @@ object RetroGlideExtension {
|
||||||
baseRequestOptions: BaseRequestOptions<*>
|
baseRequestOptions: BaseRequestOptions<*>
|
||||||
): BaseRequestOptions<*> {
|
): BaseRequestOptions<*> {
|
||||||
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
return baseRequestOptions.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
||||||
.error(DEFAULT_ERROR_ALBUM_IMAGE)
|
.error(DEFAULT_ALBUM_IMAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createSignature(song: Song): Key {
|
private fun createSignature(song: Song): Key {
|
||||||
|
|
|
@ -33,8 +33,7 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
|
||||||
|
|
||||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||||
super.onLoadFailed(errorDrawable)
|
super.onLoadFailed(errorDrawable)
|
||||||
val colors = MediaNotificationProcessor(App.getContext(), errorDrawable)
|
onColorReady(MediaNotificationProcessor.errorColor(App.getContext()))
|
||||||
onColorReady(colors)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResourceReady(
|
override fun onResourceReady(
|
||||||
|
|
|
@ -473,4 +473,12 @@ public class MediaNotificationProcessor {
|
||||||
public interface OnPaletteLoadedListener {
|
public interface OnPaletteLoadedListener {
|
||||||
void onPaletteLoaded(MediaNotificationProcessor mediaNotificationProcessor);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue