bumptech / bumptech/glide

Using Glide to load a pic from the network as a bitmap,onResourceReady invoke twice

Open
#4,562 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

```
private suspend fun loadGiftIcon(giftConf: WujiShopConfOuterClass.WujiGiftConf) = suspendCoroutine {
GlideApp.with(Env.getApplication()).asBitmap().load(CDNConstant.getCompleteUrl(giftConf.giftIcon)).addListener(object : RequestListener {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean {
it.resume(null)
return true
}

override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
val finalBitmap = resource?.let { origin ->
val scale = getFinalScale(origin, 20.dp, 20.dp)
Bitmap.createScaledBitmap(origin, (origin.width * scale).toInt(), (origin.height * scale).toInt(), true)
}
it.resume(finalBitmap)
return true
}
}).preload()
}
```

in some reason,Glide callback invoke twice. And GlideApp can be seen as normal use of Glide

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.