feat: blur function

This commit is contained in:
aayush262 2024-03-12 10:22:25 +05:30
parent bdbbe62570
commit 37c618cb28
8 changed files with 37 additions and 43 deletions

View file

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context
import android.view.View
import ani.dantotsu.R
import ani.dantotsu.blurImage
import ani.dantotsu.databinding.ItemFollowerBinding
import ani.dantotsu.loadImage
import com.bumptech.glide.Glide
@ -25,19 +26,8 @@ class FollowerItem(
override fun bind(viewBinding: ItemFollowerBinding, position: Int) {
binding = viewBinding
binding.profileUserName.text = name
val context = binding.profileBannerImage.context
avatar?.let { binding.profileUserAvatar.loadImage(it) }
if (banner != null) {
binding.profileBannerImage.loadImage(banner)
if (!(context as Activity).isDestroyed)
Glide.with(context as Context)
.load(GlideUrl(banner))
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400)
.apply(RequestOptions.bitmapTransform(BlurTransformation(2, 2)))
.into(binding.profileBannerImage)
} else {
binding.profileBannerImage.setImageResource(R.drawable.linear_gradient_bg)
}
blurImage(binding.profileBannerImage, banner ?: avatar)
binding.root.setOnClickListener { clickCallback(id) }
}