Skip to content

Instantly share code, notes, and snippets.

@chethann
Created November 29, 2016 15:13
Show Gist options
  • Save chethann/722f30745eda5b74f78c44f1f2dcdaba to your computer and use it in GitHub Desktop.
Save chethann/722f30745eda5b74f78c44f1f2dcdaba to your computer and use it in GitHub Desktop.
try {
CacheKey cacheKey = new SimpleCacheKey(url);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
final byte[] byteArray = stream.toByteArray();
Fresco.getImagePipelineFactory().getMainDiskStorageCache().insert(cacheKey, new WriterCallback() {
@Override
public void write(OutputStream outputStream) throws IOException {
outputStream.write(byteArray);
}
});
} catch (IOException cacheWriteException) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment