use of com.koushikdutta.ion.bitmap.PostProcess in project ion by koush.
the class BitmapCallback method getBitmapSnapshot.
public static void getBitmapSnapshot(final Ion ion, final String transformKey, final ArrayList<PostProcess> postProcess) {
// don't do this if this is already loading
if (ion.bitmapsPending.tag(transformKey) != null)
return;
final BitmapCallback callback = new LoadBitmapBase(ion, transformKey, true);
Ion.getBitmapLoadExecutorService().execute(new Runnable() {
@Override
public void run() {
if (ion.bitmapsPending.tag(transformKey) != callback) {
// Log.d("IonBitmapLoader", "Bitmap cache load cancelled (no longer needed)");
return;
}
try {
File file = ion.responseCache.getFileCache().getFile(transformKey);
Bitmap bitmap = IonBitmapCache.loadBitmap(file, null);
if (bitmap == null)
throw new Exception("Bitmap failed to load");
BitmapInfo info = new BitmapInfo(transformKey, "image/jpeg", bitmap, null);
info.servedFrom = ResponseServedFrom.LOADED_FROM_CACHE;
if (postProcess != null) {
for (PostProcess p : postProcess) {
p.postProcess(info);
}
}
callback.report(null, info);
} catch (OutOfMemoryError e) {
callback.report(new Exception(e), null);
} catch (Exception e) {
callback.report(e, null);
try {
ion.responseCache.getFileCache().remove(transformKey);
} catch (Exception ex) {
}
}
}
});
}
Aggregations