cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [4/7] git commit: CB-1826 Android: Guard against content provider not supplying orientation
Date Fri, 28 Feb 2014 21:33:32 GMT
CB-1826 Android: Guard against content provider not supplying orientation


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/f3a704b5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/f3a704b5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/f3a704b5

Branch: refs/heads/master
Commit: f3a704b59dbe43af6c54912e05d2e2bfb1a4ebd8
Parents: 4ae4414
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Feb 24 14:30:28 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Feb 24 14:30:28 2014 -0500

----------------------------------------------------------------------
 src/android/CameraLauncher.java | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/f3a704b5/src/android/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java
index d4ba168..57878ab 100755
--- a/src/android/CameraLauncher.java
+++ b/src/android/CameraLauncher.java
@@ -534,14 +534,18 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
     }
 
     private int getImageOrientation(Uri uri) {
-        String[] cols = { MediaStore.Images.Media.ORIENTATION };
-        Cursor cursor = cordova.getActivity().getContentResolver().query(uri,
-                cols, null, null, null);
         int rotate = 0;
-        if (cursor != null) {
-            cursor.moveToPosition(0);
-            rotate = cursor.getInt(0);
-            cursor.close();
+        String[] cols = { MediaStore.Images.Media.ORIENTATION };
+        try {
+            Cursor cursor = cordova.getActivity().getContentResolver().query(uri,
+                    cols, null, null, null);
+            if (cursor != null) {
+                cursor.moveToPosition(0);
+                rotate = cursor.getInt(0);
+                cursor.close();
+            }
+        } catch (Exception e) {
+            // You can get an IllegalArgumentException if ContentProvider doesn't support
querying for orientation.
         }
         return rotate;
     }


Mime
View raw message