Improve color picking
This commit is contained in:
parent
52bb981549
commit
4960e08fe9
4 changed files with 16 additions and 9 deletions
|
@ -262,14 +262,14 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
||||||
.dontTransform()
|
.dontTransform()
|
||||||
.into(object : RetroMusicColoredTarget(image) {
|
.into(object : RetroMusicColoredTarget(image) {
|
||||||
override fun onColorReady(colors: MediaNotificationProcessor) {
|
override fun onColorReady(colors: MediaNotificationProcessor) {
|
||||||
setColors(colors.primaryTextColor)
|
setColors(colors)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setColors(color: Int) {
|
private fun setColors(color: MediaNotificationProcessor) {
|
||||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
||||||
color.ripAlpha()
|
color.backgroundColor.ripAlpha()
|
||||||
else
|
else
|
||||||
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||||
|
|
||||||
|
|
|
@ -248,14 +248,14 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
||||||
ArtistGlideRequest.Builder.from(Glide.with(this), artist).generatePalette(this).build()
|
ArtistGlideRequest.Builder.from(Glide.with(this), artist).generatePalette(this).build()
|
||||||
.dontAnimate().into(object : RetroMusicColoredTarget(image) {
|
.dontAnimate().into(object : RetroMusicColoredTarget(image) {
|
||||||
override fun onColorReady(colors: MediaNotificationProcessor) {
|
override fun onColorReady(colors: MediaNotificationProcessor) {
|
||||||
setColors(colors.backgroundColor)
|
setColors(colors)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setColors(color: Int) {
|
private fun setColors(color: MediaNotificationProcessor) {
|
||||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
||||||
color.ripAlpha()
|
color.backgroundColor.ripAlpha()
|
||||||
else
|
else
|
||||||
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package code.name.monkey.retromusic.glide
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.retromusic.App
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteTarget
|
import code.name.monkey.retromusic.glide.palette.BitmapPaletteTarget
|
||||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
|
@ -33,8 +34,11 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
|
||||||
|
|
||||||
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
|
override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
|
||||||
super.onLoadFailed(e, errorDrawable)
|
super.onLoadFailed(e, errorDrawable)
|
||||||
val colors = MediaNotificationProcessor(getView().context, errorDrawable)
|
val colors = MediaNotificationProcessor(App.getContext(),errorDrawable)
|
||||||
onColorReady(colors)
|
onColorReady(colors)
|
||||||
|
/* MediaNotificationProcessor(App.getContext()).getPaletteAsync({
|
||||||
|
onColorReady(it)
|
||||||
|
}, errorDrawable)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResourceReady(
|
override fun onResourceReady(
|
||||||
|
@ -42,8 +46,10 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
|
||||||
glideAnimation: GlideAnimation<in BitmapPaletteWrapper>?
|
glideAnimation: GlideAnimation<in BitmapPaletteWrapper>?
|
||||||
) {
|
) {
|
||||||
super.onResourceReady(resource, glideAnimation)
|
super.onResourceReady(resource, glideAnimation)
|
||||||
resource?.let {
|
resource?.let { bitmapWrap ->
|
||||||
onColorReady(MediaNotificationProcessor(getView().context, it.bitmap))
|
MediaNotificationProcessor(App.getContext()).getPaletteAsync({
|
||||||
|
onColorReady(it)
|
||||||
|
}, bitmapWrap.bitmap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,6 +489,7 @@ public class MediaNotificationProcessor {
|
||||||
return primaryTextColor;
|
return primaryTextColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface OnPaletteLoadedListener {
|
public interface OnPaletteLoadedListener {
|
||||||
void onPaletteLoaded(MediaNotificationProcessor mediaNotificationProcessor);
|
void onPaletteLoaded(MediaNotificationProcessor mediaNotificationProcessor);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue