Android Glide load origin Bitmap, Kotlin
Kotlin
Glide.with(this)
.asBitmap()
.load(R.mipmap.p)
.addListener(object : RequestListener<Bitmap> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>, isFirstResource: Boolean): Boolean {
return false
}
override fun onResourceReady(
resource: Bitmap,
model: Any,
target: Target<Bitmap>?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
Log.d("fly", "a ${resource.height} ${resource.width}")
return false
}
})
.preload()
Glide.with(this)
.asBitmap()
.load(R.mipmap.p)
.into(object : CustomTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
Log.d("fly", "b ${resource.height} ${resource.width}")
}
override fun onLoadCleared(placeholder: Drawable?) {
}
})
val target = PreloadTarget.obtain<Bitmap>(Glide.with(this), 150, 250)
Glide.with(this)
.asBitmap()
.load(R.mipmap.p)
.addListener(object : RequestListener<Bitmap> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>, isFirstResource: Boolean): Boolean {
return false
}
override fun onResourceReady(
resource: Bitmap,
model: Any,
target: Target<Bitmap>?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
Log.d("fly", "c ${resource.height} ${resource.width}")
return false
}
})
.into(target)
D a 2414 3697
D b 2414 3697
D c 250 383