即使 url 返回 301 状态,如何使用 Glide 加载图像?
我正在尝试使用 Glide 加载图像。
当 url 返回 200 状态时它有效,但有时服务器返回状态为 301 的图像。 使用 200 或 301 图像可以正确显示在浏览器中。
滑翔似乎不喜欢它。
我该怎么处理这个问题?
Glide.with(ctx)
.asBitmap()
.load(url)
.apply(options)
.error(imgError)
.override(width,height)
.transition(BitmapTransitionOptions.withCrossFade(GLIDE_TIME_TRANSITION))
.addListener(object : RequestListener<Bitmap> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>?, isFirstResource: Boolean): Boolean {
// WHAT TO DO HERE ?
return false
}
override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target<Bitmap>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
return false
}
})
.into(this)
我想我必须在 onLoadFailed 中做一些事情,但我不确定,也不知道如何实现它......
感谢您的帮助。
I'm trying to load images with Glide.
It works when url return a 200 status but sometimes the server return the image with a status 301.
With 200 or 301 the image is correctly showing in the browser.
Glide doesn’t seem to like it.
How am I supposed to handle this ?
Glide.with(ctx)
.asBitmap()
.load(url)
.apply(options)
.error(imgError)
.override(width,height)
.transition(BitmapTransitionOptions.withCrossFade(GLIDE_TIME_TRANSITION))
.addListener(object : RequestListener<Bitmap> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Bitmap>?, isFirstResource: Boolean): Boolean {
// WHAT TO DO HERE ?
return false
}
override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target<Bitmap>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
return false
}
})
.into(this)
I think I have to do something in onLoadFailed but I'm not sure and I dont know how to achieve it...
Thank's for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论