This commit is contained in:
parent
554b25698f
commit
1ad529067d
@ -3,11 +3,9 @@ package bou.amine.apps.readerforselfossv2.android.utils.glide
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
|
|
||||||
import bou.amine.apps.readerforselfossv2.android.utils.CircleImageView
|
import bou.amine.apps.readerforselfossv2.android.utils.CircleImageView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.request.target.BitmapImageViewTarget
|
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
@ -19,22 +17,6 @@ fun Context.bitmapCenterCrop(url: String, iv: ImageView) =
|
|||||||
.apply(RequestOptions.centerCropTransform())
|
.apply(RequestOptions.centerCropTransform())
|
||||||
.into(iv)
|
.into(iv)
|
||||||
|
|
||||||
fun Context.circularBitmapDrawable(url: String, iv: ImageView) =
|
|
||||||
Glide.with(this)
|
|
||||||
.asBitmap()
|
|
||||||
.load(url)
|
|
||||||
.apply(RequestOptions.centerCropTransform())
|
|
||||||
.into(object : BitmapImageViewTarget(iv) {
|
|
||||||
override fun setResource(resource: Bitmap?) {
|
|
||||||
val circularBitmapDrawable = RoundedBitmapDrawableFactory.create(
|
|
||||||
resources,
|
|
||||||
resource
|
|
||||||
)
|
|
||||||
circularBitmapDrawable.isCircular = true
|
|
||||||
iv.setImageDrawable(circularBitmapDrawable)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
fun Context.circularDrawable(url: String, view: CircleImageView) {
|
fun Context.circularDrawable(url: String, view: CircleImageView) {
|
||||||
view.textView.text =""
|
view.textView.text =""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user