incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [36/50] [abbrv] js commit: [android] Init exec() mode on first call instead of through a timeout.
Date Fri, 24 Aug 2012 21:57:39 GMT
[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/bfc880e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/bfc880e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/bfc880e5

Branch: refs/heads/master
Commit: bfc880e51798315ca7303bf7f0a1eba84ef35849
Parents: e4887d6
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Aug 23 15:47:09 2012 -0400
Committer: Anis Kadri <anis.kadri@gmail.com>
Committed: Fri Aug 24 13:49:59 2012 -0700

----------------------------------------------------------------------
 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/bfc880e5/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/bfc880e5/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() {


Mime
View raw message