Fixed. App crashes when previewing an image
authorjabarros <jabarros@solidgear.es>
Fri, 5 Dec 2014 08:33:34 +0000 (09:33 +0100)
committerjabarros <jabarros@solidgear.es>
Fri, 5 Dec 2014 08:33:34 +0000 (09:33 +0100)
src/com/owncloud/android/ui/preview/PreviewImageFragment.java

index 269e25e..4af0128 100644 (file)
@@ -395,17 +395,23 @@ public class PreviewImageFragment extends FileFragment {
                 if (result == null) {
                     mErrorMessageId = R.string.preview_image_error_unknown_format;
                     Log_OC.e(TAG, "File could not be loaded as a bitmap: " + storagePath);
+                } else {
+                    // Rotate image, obeying exif tag.
+                    result = BitmapUtils.rotateImage(result, storagePath);
                 }
                 
             } catch (OutOfMemoryError e) {
                 Log_OC.e(TAG, "Out of memory occured for file " + storagePath, e);
 
-                // If out of memory error when loading image, try to load it scaled
+                // If out of memory error when loading or rotating image, try to load it scaled
                 result = loadScaledImage(storagePath);
 
                 if (result == null) {
                     mErrorMessageId = R.string.preview_image_error_unknown_format;
                     Log_OC.e(TAG, "File could not be loaded as a bitmap: " + storagePath);
+                } else {
+                    // Rotate scaled image, obeying exif tag
+                    result = BitmapUtils.rotateImage(result, storagePath);
                 }
                     
             } catch (NoSuchFieldError e) {
@@ -418,10 +424,6 @@ public class PreviewImageFragment extends FileFragment {
                 
             }
             
-            // Rotate image, obeying exif tag
-            result = BitmapUtils.rotateImage(result, storagePath);
-           
-            
             return result;
         }