я загружать изображения, используя Glide
как например:Сохранить изображение как только Glide загрузил его
Glide.with(getContext()).load(apdInfo.url)
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(apd_image);
И хотите сохранить Bitmap загружается как например:
private void saveImage() {
final ImageView apd_image = (ImageView) view.findViewById(R.id.apd_image);
final InternalFileHandler IFH = new InternalFileHandler(getContext());
apd_image.setDrawingCacheEnabled(true);
apd_image.buildDrawingCache(true);
Bitmap bitmap = apd_image.getDrawingCache();
// Simply saves the bitmap in the filesystem
IFH.savePicture("APD", bitmap, getContext());
apd_image.destroyDrawingCache();
}
Вопрос заключается в том, что если я называю saveImage
до Glide
загрузил мою фотографию, это не сработает.
Как подождать или Glide
загрузить? Обратите внимание, что прослушивание Glide
слушателей не помогло.
EDIT:
теперь я использую следующие слушатели:
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
//handle the exception.
return true;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
// onResourceReady is called twice for some reason, this is my work around for now
if (first) {
GlideBitmapDrawable glideBitmapDrawable = (GlideBitmapDrawable) resource;
// Convert to Bitmap
Bitmap bm = glideBitmapDrawable.getBitmap();
saveImage(bm);
first = false;
} else {
first = true;
}
return true;
}
})
что именно не работает и как? –