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 2012/08/23 21:48:57 UTC

js commit: [android] Init exec() mode on first call instead of through a timeout.

Updated Branches:
  refs/heads/master f8b6816a5 -> c1be5b651


[android] Init exec() mode on first call instead of through a timeout.


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

Branch: refs/heads/master
Commit: c1be5b651974715f97690130a0a26d6e8d5f79be
Parents: f8b6816
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Aug 23 15:47:09 2012 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Aug 23 15:47:09 2012 -0400

----------------------------------------------------------------------
 lib/android/exec.js     |   27 +++++++++++----------------
 lib/android/platform.js |    5 -----
 2 files changed, 11 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c1be5b65/lib/android/exec.js
----------------------------------------------------------------------
diff --git a/lib/android/exec.js b/lib/android/exec.js
index 0f18970..0371534 100644
--- a/lib/android/exec.js
+++ b/lib/android/exec.js
@@ -42,6 +42,17 @@ var cordova = require('cordova'),
     };
 
 function androidExec(success, fail, service, action, args) {
+    // Set default bridge modes if they have not already been set.
+    if (jsToNativeBridgeMode === undefined) {
+        androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
+    }
+    if (nativeToJsBridgeMode === undefined) {
+        if (callback.isAvailable()) {
+            androidExec.setNativeToJsBridgeMode(nativeToJsModes.HANGING_GET);
+        } else {
+            androidExec.setNativeToJsBridgeMode(nativeToJsModes.POLLING);
+        }
+    }
     try {
       var callbackId = service + cordova.callbackId++,
           argsJson = JSON.stringify(args),
@@ -158,20 +169,4 @@ androidExec.setNativeToJsBridgeMode = function(mode) {
     }
 };
 
-// Start listening for XHR callbacks
-// Figure out which bridge approach will work on this Android
-// device: polling or XHR-based callbacks
-androidExec.initialize = function() {
-    if (jsToNativeBridgeMode === undefined) {
-        androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
-    }
-    if (nativeToJsBridgeMode === undefined) {
-        if (callback.isAvailable()) {
-            androidExec.setNativeToJsBridgeMode(nativeToJsModes.HANGING_GET);
-        } else {
-            androidExec.setNativeToJsBridgeMode(nativeToJsModes.POLLING);
-        }
-    }
-};
-
 module.exports = androidExec;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c1be5b65/lib/android/platform.js
----------------------------------------------------------------------
diff --git a/lib/android/platform.js b/lib/android/platform.js
index 442f9f7..29b87fc 100644
--- a/lib/android/platform.js
+++ b/lib/android/platform.js
@@ -5,11 +5,6 @@ module.exports = {
             cordova = require('cordova'),
             exec = require('cordova/exec');
 
-        // Use a setTimeout here to give apps a chance to set the bridge mode.
-        setTimeout(function() {
-            exec.initialize();
-        }, 1);
-
         // Inject a listener for the backbutton on the document.
         var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
             onSubscribe:function() {