I want to load bitmap from server using Glide. If it's success then put it in my ImageView then add it to my ArrayList. If it's fail (broken url, no internet, etc) then set ImageView to my default image. But Glide's listener not working at all, also LogCat not show "onException" and "onResourceReady" at all. What's wrong with my code?
Glide.with(activity.getApplicationContext())
.load(MainActivity.URL_SERVER + "/asset/" + imageUrl.getString(i))
.signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
ivImage.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.noimage));
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
ivImage.setImageDrawable(resource);
imageLoadedBitmap.add(((GlideBitmapDrawable) resource).getBitmap());
return false;
}
});