实际上,我是Kotlin的新手,一直在从事一个项目,对此一无所知,在发布此问题之前,我看过其他几篇文章和帖子,但没有一篇对您有所帮助。
Here's the actual shot from the Android Studio
这段代码有什么问题?
还说...
onException overrides nothing.
onResourceReady overrides nothing.
Glide.with(this@SetupUserActivity).load(storedPhotoUrl)
.listener(object : RequestListener<String, Drawable> {
override fun onException(e: Exception?, model: String?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
progress_bar_setup_user_img.visibility = View.GONE
return false; }
override fun onResourceReady(resource: Drawable?, model: String?, target: Target<Drawable>?, isFromMemoryCache: Boolean, isFirstResource: Boolean): Boolean {
progress_bar_setup_user_img.visibility = View.GONE
return false
}
}).into(user_img_setup)
}
} catch (e: Exception) {
e.printStackTrace()
}
答案 0 :(得分:0)
尝试将您的请求侦听器更改为object : RequestListener<Drawable>
Glide.with(this@SetupUserActivity).load(storedPhotoUrl)
.listener(object : RequestListener<Drawable> {
.........
我认为您遇到该问题的原因是因为您可能会覆盖错误的RequestListener
。
尝试查看此帖子以获取其他帮助:Glide callback after success in Kotlin
您必须重写这些方法:
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
答案 1 :(得分:0)
尝试一下
Glide.with(this@SetupUserActivity).load(storedPhotoUrl)
.listener(object : RequestListener< Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}).into(user_img_setup)