incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject [1/2] android commit: Enable onMessage() to return a value.
Date Tue, 15 May 2012 15:00:35 GMT
Updated Branches:
  refs/heads/CordovaWebView 441785b51 -> d683bd374


Enable onMessage() to return a value.


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/d683bd37
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/d683bd37
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/d683bd37

Branch: refs/heads/CordovaWebView
Commit: d683bd37441a9b19f9777ec4c60b74d4c3a67867
Parents: 9f5f497
Author: Bryce Curtis <curtis.bryce@gmail.com>
Authored: Tue May 15 10:00:02 2012 -0500
Committer: Bryce Curtis <curtis.bryce@gmail.com>
Committed: Tue May 15 10:00:02 2012 -0500

----------------------------------------------------------------------
 framework/src/org/apache/cordova/AudioHandler.java |    4 +++-
 framework/src/org/apache/cordova/DroidGap.java     |    4 +++-
 .../org/apache/cordova/api/CordovaInterface.java   |    3 ++-
 framework/src/org/apache/cordova/api/IPlugin.java  |    3 ++-
 framework/src/org/apache/cordova/api/Plugin.java   |    4 +++-
 .../src/org/apache/cordova/api/PluginManager.java  |   14 +++++++++++---
 6 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d683bd37/framework/src/org/apache/cordova/AudioHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AudioHandler.java b/framework/src/org/apache/cordova/AudioHandler.java
index 8acb52c..1de3cfb 100755
--- a/framework/src/org/apache/cordova/AudioHandler.java
+++ b/framework/src/org/apache/cordova/AudioHandler.java
@@ -140,8 +140,9 @@ public class AudioHandler extends Plugin {
      * 
      * @param id            The message id
      * @param data          The message data
+     * @return              Object to stop propagation or null
      */
-    public void onMessage(String id, Object data) {
+    public Object onMessage(String id, Object data) {
 
         // If phone message
         if (id.equals("telephone")) {
@@ -167,6 +168,7 @@ public class AudioHandler extends Plugin {
                 this.pausedForPhone.clear();
             }
         }
+        return null;
     }
 
     //--------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d683bd37/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 21164e3..aeca772 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -1050,8 +1050,9 @@ public class DroidGap extends Activity implements CordovaInterface {
      * 
      * @param id            The message id
      * @param data          The message data
+     * @return              Object or null
      */
-    public void onMessage(String id, Object data) {
+    public Object onMessage(String id, Object data) {
         LOG.d(TAG, "onMessage(" + id + "," + data + ")");
         if ("splashscreen".equals(id)) {
             if ("hide".equals(data.toString())) {
@@ -1079,6 +1080,7 @@ public class DroidGap extends Activity implements CordovaInterface {
         else if ("exit".equals(id)) {
             this.endActivity();
         }
+        return null;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d683bd37/framework/src/org/apache/cordova/api/CordovaInterface.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/CordovaInterface.java b/framework/src/org/apache/cordova/api/CordovaInterface.java
index c4a1925..fa6e1f8 100755
--- a/framework/src/org/apache/cordova/api/CordovaInterface.java
+++ b/framework/src/org/apache/cordova/api/CordovaInterface.java
@@ -73,7 +73,8 @@ public interface CordovaInterface {
      * 
      * @param id            The message id
      * @param data          The message data
+     * @return              Object or null
      */
-    public void onMessage(String id, Object data);
+    public Object onMessage(String id, Object data);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d683bd37/framework/src/org/apache/cordova/api/IPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/IPlugin.java b/framework/src/org/apache/cordova/api/IPlugin.java
index 173a304..e410ac9 100755
--- a/framework/src/org/apache/cordova/api/IPlugin.java
+++ b/framework/src/org/apache/cordova/api/IPlugin.java
@@ -94,8 +94,9 @@ public interface IPlugin {
      * 
      * @param id            The message id
      * @param data          The message data
+     * @return              Object to stop propagation or null
      */
-    public void onMessage(String id, Object data);
+    public Object onMessage(String id, Object data);
 
     /**
      * Called when an activity you launched exits, giving you the requestCode you started
it with,

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d683bd37/framework/src/org/apache/cordova/api/Plugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/Plugin.java b/framework/src/org/apache/cordova/api/Plugin.java
index 2e6d462..871a964 100755
--- a/framework/src/org/apache/cordova/api/Plugin.java
+++ b/framework/src/org/apache/cordova/api/Plugin.java
@@ -107,8 +107,10 @@ public abstract class Plugin implements IPlugin {
      * 
      * @param id            The message id
      * @param data          The message data
+     * @return              Object to stop propagation or null
      */
-    public void onMessage(String id, Object data) {
+    public Object onMessage(String id, Object data) {
+        return null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/d683bd37/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index fa40e07..1714eb8 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -314,14 +314,22 @@ public class PluginManager {
      * 
      * @param id                The message id
      * @param data              The message data
+     * @return
      */
-    public void postMessage(String id, Object data) {
-        this.ctx.onMessage(id, data);
+    public Object postMessage(String id, Object data) {
+        Object obj = this.ctx.onMessage(id, data);
+        if (obj != null) {
+            return obj;
+        }
         for (PluginEntry entry : this.entries.values()) {
             if (entry.plugin != null) {
-                entry.plugin.onMessage(id, data);
+                obj = entry.plugin.onMessage(id, data);
+                if (obj != null) {
+                    return obj;
+                }
             }
         }
+        return null;
     }
 
     /**


Mime
View raw message