bumptech / bumptech/glide

Image not getting load while listener added

Open
#5,083 3 comments 3 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version**: 1.0.0-alpha.1

**Integration libraries**: com.github.bumptech.glide:compose:1.0.0-alpha.1

I am using GlideImage to load from local and url resource.

I need my callbacks(onError and onSuccess) to return if url fails to load or succeed to load. For this added inside the body of glide added the listener. As listener added image not getting loaded.

My requirements are callBacks(onError and onSuccess) to return along with image load. Please help me by your idea to resolve my challenge.

Below my code attached:

**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:
```java
Glide.with...

GlideImage(
model = src,
contentDescription = "image load",
modifier = Modifier.fillMaxSize(),
) {
it
.listener(object : RequestListener {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target?,
isFirstResource: Boolean
): Boolean {
Log.e("Glide","Failure")
state = ImageState.error
onError?.invoke()
return true
}

override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
Log.e("Glide","Success")
state = ImageState.success
onLoad?.invoke()
return true
}
})
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.