From 83ead3a3589ae5480ed5861689c790104e0791b3 Mon Sep 17 00:00:00 2001 From: fkloft Date: Sat, 1 Mar 2014 15:13:58 +0100 Subject: [PATCH] Delete drawing cache after usage --- .../com/cradle/iitc_mobile/IITC_Mobile.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 264c9f2f..075a009a 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -850,16 +850,25 @@ public class IITC_Mobile extends Activity } private void sendScreenshot() { - mIitcWebView.setDrawingCacheEnabled(true); - final Bitmap bitmap = mIitcWebView.getDrawingCache(); + Bitmap bitmap = mIitcWebView.getDrawingCache(); if (bitmap == null) { - Log.e("getDrawingCache() returned null!"); - return; + mIitcWebView.buildDrawingCache(); + bitmap = mIitcWebView.getDrawingCache(); + if (bitmap == null) { + Log.e("could not get bitmap!"); + return; + } + bitmap = Bitmap.createBitmap(bitmap); + if (!mIitcWebView.isDrawingCacheEnabled()) mIitcWebView.destroyDrawingCache(); } + else { + bitmap = Bitmap.createBitmap(bitmap); + } + try { final File cache = getExternalCacheDir(); final File file = File.createTempFile("IITC screenshot", ".png", cache); - if (!Bitmap.createBitmap(bitmap).compress(CompressFormat.PNG, 100, new FileOutputStream(file))) { + if (!bitmap.compress(CompressFormat.PNG, 100, new FileOutputStream(file))) { // quality is ignored by PNG throw new IOException("Could not compress bitmap!"); }