From 0e8c27eeb8dfc5daaf619322be275d22c4cd96f0 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 29 Aug 2021 16:40:32 -0700 Subject: Fix blur and deps --- .../allanwang/kau/mediapicker/BlurredImageView.kt | 40 ++++++++-------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'mediapicker/src/main/kotlin/ca') diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt index 8e78abf..77ac04c 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt @@ -30,8 +30,7 @@ import ca.allanwang.kau.utils.setBackgroundColorRes import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.visible import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial -import jp.wasabeef.blurry.internal.BlurFactor -import jp.wasabeef.blurry.internal.BlurTask +import jp.wasabeef.blurry.Blurry /** * Created by Allan Wang on 2017-07-14. @@ -53,7 +52,8 @@ class BlurredImageView @JvmOverloads constructor( val imageBase: ImageView get() = binding.imageBase - private val binding: KauBlurredImageviewBinding = KauBlurredImageviewBinding.inflate(LayoutInflater.from(context), this) + private val binding: KauBlurredImageviewBinding = + KauBlurredImageviewBinding.inflate(LayoutInflater.from(context), this) init { initAttrs(context, attrs) @@ -87,17 +87,12 @@ class BlurredImageView @JvmOverloads constructor( fun blur() { if (isBlurred) return isBlurred = true - val factor = BlurFactor() - factor.width = width - factor.height = height - BlurTask(imageBase, factor) { - with(binding) { - imageBlur.setImageDrawable(it) - scaleAnimate(ANIMATION_SCALE).start() - imageBlur.alphaAnimate(1f).start() - imageForeground.alphaAnimate(1f).start() - } - }.execute() + with(binding) { + Blurry.with(imageBase.context).capture(imageBase).into(imageBlur) + scaleAnimate(ANIMATION_SCALE).start() + imageBlur.alphaAnimate(1f).start() + imageForeground.alphaAnimate(1f).start() + } } /** @@ -108,17 +103,12 @@ class BlurredImageView @JvmOverloads constructor( fun blurInstantly() { isBlurred = true clearAnimation() - val factor = BlurFactor() - factor.width = width - factor.height = height - BlurTask(imageBase, factor) { drawable -> - with(binding) { - imageBlur.setImageDrawable(drawable) - scaleXY = ANIMATION_SCALE - imageBlur.alpha = 1f - imageForeground.alpha = 1f - } - }.execute() + with(binding) { + Blurry.with(imageBase.context).capture(imageBase).into(imageBlur) + scaleXY = ANIMATION_SCALE + imageBlur.alpha = 1f + imageForeground.alpha = 1f + } } /** -- cgit v1.2.3