You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/08/15 22:15:39 UTC

js commit: [android] Tweak the online bridge to tell native when an event has happened.

Updated Branches:
  refs/heads/master 6da628d54 -> 1be287663


[android] Tweak the online bridge to tell native when an event has happened.

This allows the native side to not send excess events.


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

Branch: refs/heads/master
Commit: 1be2876635d2a788270238c4b1cfad200c488e32
Parents: 6da628d
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Aug 15 15:47:27 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Aug 15 15:47:27 2013 -0400

----------------------------------------------------------------------
 lib/android/exec.js                                | 12 ++++++++----
 lib/android/plugin/android/promptbasednativeapi.js |  4 ++--
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/1be28766/lib/android/exec.js
----------------------------------------------------------------------
diff --git a/lib/android/exec.js b/lib/android/exec.js
index 08d3e56..f22c46b 100644
--- a/lib/android/exec.js
+++ b/lib/android/exec.js
@@ -103,8 +103,12 @@ function androidExec(success, fail, service, action, args) {
     }
 }
 
-function pollOnce() {
-    var msg = nativeApiProvider.get().retrieveJsMessages();
+function pollOnceFromOnlineEvent() {
+    pollOnce(true);
+}
+
+function pollOnce(opt_fromOnlineEvent) {
+    var msg = nativeApiProvider.get().retrieveJsMessages(!!opt_fromOnlineEvent);
     androidExec.processMessages(msg);
 }
 
@@ -123,8 +127,8 @@ function hookOnlineApis() {
     // It currently fires them only on document though, so we bridge them
     // to window here (while first listening for exec()-releated online/offline
     // events).
-    window.addEventListener('online', pollOnce, false);
-    window.addEventListener('offline', pollOnce, false);
+    window.addEventListener('online', pollOnceFromOnlineEvent, false);
+    window.addEventListener('offline', pollOnceFromOnlineEvent, false);
     cordova.addWindowEventHandler('online');
     cordova.addWindowEventHandler('offline');
     document.addEventListener('online', proxyEvent, false);

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/1be28766/lib/android/plugin/android/promptbasednativeapi.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/promptbasednativeapi.js b/lib/android/plugin/android/promptbasednativeapi.js
index a665135..c12f46e 100644
--- a/lib/android/plugin/android/promptbasednativeapi.js
+++ b/lib/android/plugin/android/promptbasednativeapi.js
@@ -29,7 +29,7 @@ module.exports = {
     setNativeToJsBridgeMode: function(value) {
         prompt(value, 'gap_bridge_mode:');
     },
-    retrieveJsMessages: function() {
-        return prompt('', 'gap_poll:');
+    retrieveJsMessages: function(fromOnlineEvent) {
+        return prompt(+fromOnlineEvent, 'gap_poll:');
     }
 };