saber javadi
saber javadi

Reputation: 542

android Glide resource is ready but image not showing

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) }

Upvotes: 2

Views: 2988

Answers (1)

Anes Abismail
Anes Abismail

Reputation: 344

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

Upvotes: 4

Related Questions