I use Glideto upload images to ViewPagerusing PagerAdapter. When I upload images using the following method:
Glide.with(mContext).load(mImage).placeholder(R.drawable.placeholder).into(mImageView);
Everything works fine, but now I need to get the bitmap from slipping and save it on the map when it loads for future editing, so I switched this method to the following:
Glide.with(mContext).load(mImage).asBitmap().placeholder(R.drawable.placeholder).into(new SimpleTarget<Bitmap>() {
@Override
public void onLoadStarted(Drawable placeholder) {
super.onLoadStarted(placeholder);
mImageView.setImageDrawable(placeholder);
}
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
if (bitmap != null) {
mImageView.setImageBitmap(bitmap);
}
mBitmapMap.put(position, bitmap);
mInterface.onImageLoaded(position, bitmap);
}
});
But the result is that the image is not always displayed. I think this is due to the fact that glide loads async images and at some point returns when the method is instatiateItemalready completed.
This seems to be a related issue . But the offers there did not help me. Has anyone encountered this problem and have a solution for this?