Reputation:
This is what I've tried
Glide
.with(context)
.load(imgUrl)
.listener(object : RequestListener<Drawable>{
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
return false
}
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
return false
}
})
.into(holder.image)
First error on object
:
Object is not abstract and does not implement abstract member public abstract fun onResourceReady(resource: Drawable!, model: Any!, target: Target!, dataSource: DataSource!, isFirstResource: Boolean): Boolean defined in com.bumptech.glide.request.RequestListener
Second error on Drawable
:
No type arguments expected for annotation class Target
Third error on second override
:
'onResourceReady' overrides nothing
What is wrong here? Or are there any other solutions??
Upvotes: 5
Views: 1602
Reputation: 176
Those errors occurs because you are importing the wrong version of Target class. You should import "Target" from com.bumptech.glide.request.target.Target package.
import android.graphics.drawable.Drawable
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
object : RequestListener<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
): Boolean {
return false
}
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
return false
}
}
Upvotes: 16