aboutsummaryrefslogtreecommitdiff
path: root/mediapicker
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-08-29 16:40:32 -0700
committerAllan Wang <me@allanwang.ca>2021-08-29 16:40:32 -0700
commit0e8c27eeb8dfc5daaf619322be275d22c4cd96f0 (patch)
tree696689dca3c2ae279e955084931701d9dbe7f7b9 /mediapicker
parent86e692cdb1c872259503acab642c75e1e519a537 (diff)
downloadkau-0e8c27eeb8dfc5daaf619322be275d22c4cd96f0.tar.gz
kau-0e8c27eeb8dfc5daaf619322be275d22c4cd96f0.tar.bz2
kau-0e8c27eeb8dfc5daaf619322be275d22c4cd96f0.zip
Fix blur and deps
Diffstat (limited to 'mediapicker')
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt40
1 files changed, 15 insertions, 25 deletions
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
+ }
}
/**