From: Bartek Przybylski Date: Thu, 12 Jul 2012 20:02:30 +0000 (+0200) Subject: reduce permissions, optimize bitmap displaying X-Git-Tag: oc-android-1.4.3~280 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/147227040b0b37f28d9819b6514ecf882be26547?hp=-c reduce permissions, optimize bitmap displaying --- 147227040b0b37f28d9819b6514ecf882be26547 diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 408d148f..3af24ef1 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -29,7 +29,6 @@ - @@ -41,8 +40,6 @@ - - = android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { options.inPreferQualityOverSpeed = false; } @@ -856,39 +856,36 @@ public class FileDetailFragment extends SherlockFragment implements } result = BitmapFactory.decodeFile(storagePath, options); + options.inJustDecodeBounds = false; + + int width = options.outWidth; + int height = options.outHeight; + int scale = 1; + boolean recycle = false; + if (width >= 2048 || height >= 2048) { + scale = (int) Math.ceil((Math.ceil(Math.max(height, width) / 2048.))); + options.inSampleSize = scale; + } + Display display = getActivity().getWindowManager().getDefaultDisplay(); + Point size = new Point(); + int screenwidth; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) { + display.getSize(size); + screenwidth = size.x; + } else { + screenwidth = display.getWidth(); + } - if (result != null) { - int width = options.outWidth; - int height = options.outHeight; - int scale = 1; - boolean recycle = false; - if (width >= 2048 || height >= 2048) { - scale = (int) (Math.ceil(Math.max(height, width) / 2048.)); - options.inSampleSize = scale; - recycle = true; - } - Display display = getActivity().getWindowManager().getDefaultDisplay(); - Point size = new Point(); - int screenwidth; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) { - display.getSize(size); - screenwidth = size.x; - } else { - screenwidth = display.getWidth(); - } + Log.e("ASD", "W " + width + " SW " + screenwidth); - Log.e("ASD", "W " + width + " SW " + screenwidth); + if (width > screenwidth) { + scale = (int) Math.ceil((Math.ceil(Math.max(height, width) / screenwidth))); + options.inSampleSize = scale; + } - if (width > screenwidth) { - scale = (int) (Math.ceil(Math.max(height, width) / screenwidth)); - options.inSampleSize = scale; - recycle = true; - } + result = BitmapFactory.decodeFile(storagePath, options); - if (recycle) - result.recycle(); - result = BitmapFactory.decodeFile(storagePath, options); - } + Log.e("ASD", "W " + options.outWidth + " SW " + options.outHeight); } catch (OutOfMemoryError e) { result = null;