private SimpleTarget target = new SimpleTarget() {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {
Glide.with(context)
.load(url)
.listener(object : RequestListener {
override fun onLoadFailed(p0: GlideException?, p1: Any?, p2: Target?, p3: Boolean): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onResourceReady(p0: Drawable?, p1: Any?, p2: Target?, p3: DataSource?, p4: Boolean): Boolean {
Log.d(TAG, "OnResourceReady")
//do something when picture already loaded
return false
}
})
.into(imgView)
With Glide you can add Listener to your chain, which monitor state of your image loading. You have to override two methods, in onResourceReady method you have callback that your image is already loaded and you can do something , for example hide loader or let finish animation from another view. In onLoadFailed you get information about some error while loading and also you can react somehow. This way you can avoid those errors.