incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From macdo...@apache.org
Subject android commit: CB-919: Camera Plugin returned with empty error message
Date Wed, 20 Jun 2012 16:21:12 GMT
Updated Branches:
  refs/heads/master a691e9f74 -> c1c907596


CB-919: Camera Plugin returned with empty error message

Guarding against null cursor.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/c1c90759
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/c1c90759
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/c1c90759

Branch: refs/heads/master
Commit: c1c907596233efd175ff611d35d82c53fe157577
Parents: a691e9f
Author: macdonst <simon.macdonald@gmail.com>
Authored: Wed Jun 20 12:20:37 2012 -0400
Committer: macdonst <simon.macdonald@gmail.com>
Committed: Wed Jun 20 12:20:42 2012 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CameraLauncher.java     |   22 ++++++++-------
 framework/src/org/apache/cordova/Capture.java      |   18 +++++++-----
 2 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c1c90759/framework/src/org/apache/cordova/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
index 3520247..3d43b11 100755
--- a/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/framework/src/org/apache/cordova/CameraLauncher.java
@@ -524,18 +524,20 @@ public class CameraLauncher extends Plugin {
     private void checkForDuplicateImage(int type) {
         int diff = 1;
         Cursor cursor = queryImgDB();
-        int currentNumOfImages = cursor.getCount();
+        if (cursor != null) {
+            int currentNumOfImages = cursor.getCount();
 
-        if (type == FILE_URI) {
-            diff = 2;
-        }
+            if (type == FILE_URI) {
+                diff = 2;
+            }
 
-        // delete the duplicate file if the difference is 2 for file URI or 1 for Data URL
-        if ((currentNumOfImages - numPics) == diff) {
-            cursor.moveToLast();
-            int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)))
- 1;
-            Uri uri = Uri.parse(MediaStore.Images.Media.EXTERNAL_CONTENT_URI + "/" + id);
-            this.cordova.getActivity().getContentResolver().delete(uri, null, null);
+            // delete the duplicate file if the difference is 2 for file URI or 1 for Data
URL
+            if ((currentNumOfImages - numPics) == diff) {
+                cursor.moveToLast();
+                int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)))
- 1;
+                Uri uri = Uri.parse(MediaStore.Images.Media.EXTERNAL_CONTENT_URI + "/" +
id);
+                this.cordova.getActivity().getContentResolver().delete(uri, null, null);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c1c90759/framework/src/org/apache/cordova/Capture.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Capture.java b/framework/src/org/apache/cordova/Capture.java
index cd115d4..5898dc8 100644
--- a/framework/src/org/apache/cordova/Capture.java
+++ b/framework/src/org/apache/cordova/Capture.java
@@ -424,14 +424,16 @@ public class Capture extends Plugin {
      */
     private void checkForDuplicateImage() {
         Cursor cursor = queryImgDB();
-        int currentNumOfImages = cursor.getCount();
-
-        // delete the duplicate file if the difference is 2
-        if ((currentNumOfImages - numPics) == 2) {
-            cursor.moveToLast();
-            int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)))
- 1;
-            Uri uri = Uri.parse(MediaStore.Images.Media.EXTERNAL_CONTENT_URI + "/" + id);
-            this.cordova.getActivity().getContentResolver().delete(uri, null, null);
+        if (cursor != null) {
+            int currentNumOfImages = cursor.getCount();
+
+            // delete the duplicate file if the difference is 2
+            if ((currentNumOfImages - numPics) == 2) {
+                cursor.moveToLast();
+                int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)))
- 1;
+                Uri uri = Uri.parse(MediaStore.Images.Media.EXTERNAL_CONTENT_URI + "/" +
id);
+                this.cordova.getActivity().getContentResolver().delete(uri, null, null);
+            }
         }
     }
 }


Mime
View raw message