cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject android commit: Added CallbackContext success message with an int parameter
Date Mon, 25 Feb 2013 21:46:32 GMT
Updated Branches:
  refs/heads/master 62421ee49 -> c668eeba0


Added CallbackContext success message with an int parameter

Added a small utility function to convert JSONArray to List<String>


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

Branch: refs/heads/master
Commit: c668eeba0fc8e36594777e86071a28fa70be3279
Parents: 62421ee
Author: Shravan Narayan <shravanrn@dhcp-172-23-180-146.wat.corp.google.com>
Authored: Mon Feb 25 14:00:34 2013 -0500
Committer: Shravan Narayan <shravanrn@dhcp-172-23-180-146.wat.corp.google.com>
Committed: Mon Feb 25 15:17:40 2013 -0500

----------------------------------------------------------------------
 framework/src/org/apache/cordova/JSONUtils.java    |   24 +++++++++++++++
 .../org/apache/cordova/api/CallbackContext.java    |    9 +++++
 2 files changed, 33 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c668eeba/framework/src/org/apache/cordova/JSONUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/JSONUtils.java b/framework/src/org/apache/cordova/JSONUtils.java
new file mode 100644
index 0000000..77df876
--- /dev/null
+++ b/framework/src/org/apache/cordova/JSONUtils.java
@@ -0,0 +1,24 @@
+package org.apache.cordova;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+
+public class JSONUtils {
+	public static List<String> toStringList(JSONArray array) throws JSONException {
+        if(array == null) {
+            return null;
+        }
+        else {
+            List<String> list = new ArrayList<String>();
+
+            for (int i = 0; i < array.length(); i++) {
+                list.add(array.get(i).toString());
+            }
+
+            return list;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c668eeba/framework/src/org/apache/cordova/api/CallbackContext.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/CallbackContext.java b/framework/src/org/apache/cordova/api/CallbackContext.java
index 2f7b15f..a5d1255 100644
--- a/framework/src/org/apache/cordova/api/CallbackContext.java
+++ b/framework/src/org/apache/cordova/api/CallbackContext.java
@@ -79,6 +79,15 @@ public class CallbackContext {
     public void success(byte[] message) {
         sendPluginResult(new PluginResult(PluginResult.Status.OK, message));
     }
+    
+    /**
+     * Helper for success callbacks that just returns the Status.OK by default
+     *
+     * @param message           The message to add to the success result.
+     */
+    public void success(int message) {
+        sendPluginResult(new PluginResult(PluginResult.Status.OK, message));
+    }
 
     /**
      * Helper for success callbacks that just returns the Status.OK by default


Mime
View raw message