X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/90161386e25c0760bdf75b9e6b4355a61f65f42e..4f2f33c9bcfce7fb96c149f8e50188372a3ec61b:/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java index db916414..c94719ee 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java @@ -205,7 +205,6 @@ public class FileDetailFragment extends SherlockFragment implements mDownloadFinishReceiver = null; if (mPreview != null) { mPreview = null; - System.gc(); } } @@ -848,6 +847,7 @@ public class FileDetailFragment extends SherlockFragment implements BitmapFactory.Options options = new Options(); options.inScaled = true; options.inPurgeable = true; + options.inJustDecodeBounds = true; if (android.os.Build.VERSION.SDK_INT >= 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((float)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;