I want to get Bitmap
from SimpleDraweeView
of Fresco lib, and save it to SD Card.
SimpleDraweeView
is child class of ImageView
so it should support getDrawable()
but calling this method throws ClassCastException
BitmapDrawable bitmapDrawable = (BitmapDrawable) viewHolder.drawee.getDrawable();
ClassCastException: com.facebook.drawee.generic.RootDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
What is the wayout for this?
s1rius's answer mentioned by Morrison helped me. Here's the code that I used.
ImageRequest downloadRequest = ImageRequest.fromUri(uri);
CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(downloadRequest, context);
if (ImagePipelineFactory.getInstance().getMainFileCache().hasKey(cacheKey)) {
BinaryResource resource = ImagePipelineFactory.getInstance().getMainFileCache().getResource(cacheKey);
File cacheFile = ((FileBinaryResource) resource).getFile();
File savedImageFile = new File(Constants.APP_PATH_SAVED_QUOTES, "M1iS1" + "_" + currentPosition + ".jpg");
}
Then I copied cacheFile
into savedImageFile
.