use glide to load image on a recyclerview imageview item. impelemented glide listeners i realized that image resource is ready, but image not showing in imageview. when i add imageview.setDrawable(resource) inside glide listener onResourceRady ,then image shows up but in normal not showing here is my code i appreciate any help.
GlideApp
.with(this.myContext)
.load(item.add)
.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
myContext.toast("error:\n ${e?.causes}")
return true
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
myContext.toast("resource ready")
// holder.img.setImageDrawable(resource) return true } }) .error(R.drawable.neterror) .into(holder.img) }
Glide depends on the returned boolean from the onResourceReady
method of RequestListener
, if the returned value is true
(which is your case) it means that the listener has handled setting the resource on the target. To allow Glide's request to update the target return false
. For more information checkout the docs: https://bumptech.github.io/glide/doc/debugging.html#requestlistener-and-custom-logs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.