Fixed bug when turning tablet with no file in the right fragment
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / preview / PreviewImageFragment.java
index a082b53..2f51a63 100644 (file)
@@ -2,9 +2,8 @@
  *   Copyright (C) 2012-2013 ownCloud Inc. 
  *
  *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 2 of the License, or
- *   (at your option) any later version.
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
  *
  *   This program is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -282,7 +281,7 @@ public class PreviewImageFragment extends SherlockFragment implements   FileFrag
     @Override
     public void onResume() {
         super.onResume();
-        Log.e(TAG, "FRAGMENT, ONRESUME");
+        //Log.e(TAG, "FRAGMENT, ONRESUME");
         /*
         mDownloadFinishReceiver = new DownloadFinishReceiver();
         IntentFilter filter = new IntentFilter(
@@ -533,14 +532,6 @@ public class PreviewImageFragment extends SherlockFragment implements   FileFrag
                 int height = options.outHeight;
                 int scale = 1;
                 
-                /*
-                if (width >= 2048 || height >= 2048) {  
-                    // try to scale down the image to save memory  
-                    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;
@@ -555,14 +546,13 @@ public class PreviewImageFragment extends SherlockFragment implements   FileFrag
                 }
 
                 if (width > screenWidth) {
-                    // second try to scale down the image , this time depending upon the screen size; WTF... 
-                    scale = (int) Math.ceil((float)width / screenWidth);
-                    options.inSampleSize = scale;
+                    // second try to scale down the image , this time depending upon the screen size 
+                    scale = (int) Math.floor((float)width / screenWidth);
                 }
                 if (height > screenHeight) {
-                    scale = Math.max(scale, (int) Math.ceil((float)height / screenHeight));
+                    scale = Math.max(scale, (int) Math.floor((float)height / screenHeight));
                 }
-                
+                options.inSampleSize = scale;
 
                 // really load the bitmap
                 options.inJustDecodeBounds = false; // the next decodeFile call will be real