Improvements in load of images: progress wheel while loading and better scaling
authorDavid A. Velasco <dvelasco@solidgear.es>
Fri, 1 Mar 2013 10:17:12 +0000 (11:17 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Fri, 1 Mar 2013 10:17:12 +0000 (11:17 +0100)
src/com/owncloud/android/ui/preview/PreviewImageActivity.java
src/com/owncloud/android/ui/preview/PreviewImageFragment.java

index 5148987..47406be 100644 (file)
@@ -237,7 +237,7 @@ public class PreviewImageActivity extends SherlockFragmentActivity implements Fi
     @Override
     protected void onResume() {
         super.onResume();
     @Override
     protected void onResume() {
         super.onResume();
-        Log.e(TAG, "ACTIVITY, ONRESUME");
+        //Log.e(TAG, "ACTIVITY, ONRESUME");
         mDownloadFinishReceiver = new DownloadFinishReceiver();
         IntentFilter filter = new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
         registerReceiver(mDownloadFinishReceiver, filter);
         mDownloadFinishReceiver = new DownloadFinishReceiver();
         IntentFilter filter = new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
         registerReceiver(mDownloadFinishReceiver, filter);
@@ -245,7 +245,7 @@ public class PreviewImageActivity extends SherlockFragmentActivity implements Fi
 
     @Override
     protected void onPostResume() {
 
     @Override
     protected void onPostResume() {
-        Log.e(TAG, "ACTIVITY, ONPOSTRESUME");
+        //Log.e(TAG, "ACTIVITY, ONPOSTRESUME");
         super.onPostResume();
     }
     
         super.onPostResume();
     }
     
index a082b53..77cbc49 100644 (file)
@@ -282,7 +282,7 @@ public class PreviewImageFragment extends SherlockFragment implements   FileFrag
     @Override
     public void onResume() {
         super.onResume();
     @Override
     public void onResume() {
         super.onResume();
-        Log.e(TAG, "FRAGMENT, ONRESUME");
+        //Log.e(TAG, "FRAGMENT, ONRESUME");
         /*
         mDownloadFinishReceiver = new DownloadFinishReceiver();
         IntentFilter filter = new IntentFilter(
         /*
         mDownloadFinishReceiver = new DownloadFinishReceiver();
         IntentFilter filter = new IntentFilter(
@@ -533,14 +533,6 @@ public class PreviewImageFragment extends SherlockFragment implements   FileFrag
                 int height = options.outHeight;
                 int scale = 1;
                 
                 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;
                 Display display = getActivity().getWindowManager().getDefaultDisplay();
                 Point size = new Point();
                 int screenWidth;
@@ -555,14 +547,13 @@ public class PreviewImageFragment extends SherlockFragment implements   FileFrag
                 }
 
                 if (width > screenWidth) {
                 }
 
                 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) {
                 }
                 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
 
                 // really load the bitmap
                 options.inJustDecodeBounds = false; // the next decodeFile call will be real