aboutsummaryrefslogtreecommitdiff
path: root/mediapicker
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-09-11 13:44:39 -0700
committerGitHub <noreply@github.com>2021-09-11 13:44:39 -0700
commit777d22a2cd252c0cb6f6898c57b5e565f90d59a6 (patch)
tree82f18c8758e341ccc189e406da2c819c18ccf819 /mediapicker
parent6492c0c9c1c008dc8cbd43ee5955d9955c782d91 (diff)
parentf406b888ff2108dee310260c29af8c3c2cce4f2d (diff)
downloadkau-777d22a2cd252c0cb6f6898c57b5e565f90d59a6.tar.gz
kau-777d22a2cd252c0cb6f6898c57b5e565f90d59a6.tar.bz2
kau-777d22a2cd252c0cb6f6898c57b5e565f90d59a6.zip
Merge pull request #262 from AllanWang/version
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
+ }
}
/**