cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [1/2] cordova-plugin-camera git commit: Fix for CB-10625
Date Mon, 22 Feb 2016 19:54:28 GMT
Repository: cordova-plugin-camera
Updated Branches:
  refs/heads/master 61b77951e -> 16636d18f


Fix for CB-10625

getDocumentId was crashing in some cases.
Now, in case it crashes, it will use the original uri to query.


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/019346d1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/019346d1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/019346d1

Branch: refs/heads/master
Commit: 019346d18839d966c04fa41093c6f64de3a8e3e0
Parents: 61b7795
Author: Julio C├ęsar <jcesarmobile@gmail.com>
Authored: Sun Feb 21 21:00:14 2016 +0100
Committer: Joe Bowser <bowserj@apache.org>
Committed: Mon Feb 22 11:23:53 2016 -0800

----------------------------------------------------------------------
 src/android/FileHelper.java | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/019346d1/src/android/FileHelper.java
----------------------------------------------------------------------
diff --git a/src/android/FileHelper.java b/src/android/FileHelper.java
index 59f890e..f772061 100644
--- a/src/android/FileHelper.java
+++ b/src/android/FileHelper.java
@@ -80,18 +80,25 @@ public class FileHelper {
     public static String getRealPathFromURI_API19(Context context, Uri uri) {
         String filePath = "";
         try {
-            String wholeID = DocumentsContract.getDocumentId(uri);
 
-            // Split at colon, use second item in the array
-            String id = wholeID.indexOf(":") > -1 ? wholeID.split(":")[1] : wholeID.indexOf(";")
> -1 ? wholeID
-                    .split(";")[1] : wholeID;
+            String id = null;
+            Uri myUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;;
+            try {
+                String wholeID = DocumentsContract.getDocumentId(uri);
+
+                // Split at colon, use second item in the array
+                id = wholeID.indexOf(":") > -1 ? wholeID.split(":")[1] : wholeID.indexOf(";")
> -1 ? wholeID
+                        .split(";")[1] : wholeID;
+            } catch (Exception e) {
+                myUri = uri;
+            }
 
             String[] column = { MediaStore.Images.Media.DATA };
 
             // where id is equal to
             String sel = MediaStore.Images.Media._ID + "=?";
 
-            Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
column,
+            Cursor cursor = context.getContentResolver().query(myUri, column,
                     sel, new String[] { id }, null);
 
             int columnIndex = cursor.getColumnIndex(column[0]);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message