PlayerAndroid/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.kt

50 lines
1.9 KiB
Kotlin
Raw Normal View History

2019-03-03 09:20:15 +00:00
/*
2020-10-06 08:46:04 +00:00
* Copyright (c) 2020 Hemanth Savarla.
2019-03-03 09:20:15 +00:00
*
* Licensed under the GNU General Public License v3
*
2020-10-06 08:46:04 +00:00
* This is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
2019-03-03 09:20:15 +00:00
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
2020-10-06 08:46:04 +00:00
*
2019-03-03 09:20:15 +00:00
*/
2018-11-30 01:06:16 +00:00
package code.name.monkey.retromusic.glide
import android.graphics.drawable.Drawable
import android.widget.ImageView
import code.name.monkey.appthemehelper.util.ATHUtil
2020-05-14 14:36:34 +00:00
import code.name.monkey.retromusic.App
2018-11-30 01:06:16 +00:00
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.glide.palette.BitmapPaletteTarget
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.request.transition.Transition
2018-11-30 01:06:16 +00:00
abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(view) {
protected val defaultFooterColor: Int
2020-01-24 16:54:08 +00:00
get() = ATHUtil.resolveColor(getView().context, R.attr.colorControlNormal)
2018-11-30 01:06:16 +00:00
abstract fun onColorReady(colors: MediaNotificationProcessor)
2019-09-22 18:56:40 +00:00
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
2020-05-23 13:53:10 +00:00
val colors = MediaNotificationProcessor(App.getContext(), errorDrawable)
onColorReady(colors)
2018-11-30 01:06:16 +00:00
}
override fun onResourceReady(
resource: BitmapPaletteWrapper,
transition: Transition<in BitmapPaletteWrapper>?
) {
super.onResourceReady(resource, transition)
MediaNotificationProcessor(App.getContext()).getPaletteAsync({
onColorReady(it)
}, resource.bitmap)
2018-11-30 01:06:16 +00:00
}
}