You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/08/24 23:57:38 UTC

[6/50] [abbrv] js commit: [android] Implement JS->Native exec() based off of location change.

[android] Implement JS->Native exec() based off of location change.


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

Branch: refs/heads/master
Commit: c5980711088d03cf260f037877f4be35344e1930
Parents: c26fa40
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Aug 24 14:05:10 2012 -0400
Committer: Anis Kadri <an...@gmail.com>
Committed: Fri Aug 24 13:50:04 2012 -0700

----------------------------------------------------------------------
 lib/android/exec.js |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c5980711/lib/android/exec.js
----------------------------------------------------------------------
diff --git a/lib/android/exec.js b/lib/android/exec.js
index 0371534..e0ab09c 100644
--- a/lib/android/exec.js
+++ b/lib/android/exec.js
@@ -20,7 +20,10 @@ var cordova = require('cordova'),
     jsToNativeModes = {
         PROMPT: 0,
         JS_OBJECT: 1,
-        LOCATION_CHANGE: 2  // Not yet implemented
+        // This mode is currently for benchmarking purposes only. It must be enabled
+        // on the native side through the ENABLE_LOCATION_CHANGE_EXEC_MODE
+        // constant within CordovaWebViewClient.java before it will work.
+        LOCATION_CHANGE: 2
     },
     nativeToJsModes = {
         // Polls for messages using the prompt() bridge.
@@ -61,7 +64,9 @@ function androidExec(success, fail, service, action, args) {
           cordova.callbacks[callbackId] = {success:success, fail:fail};
       }
 
-      if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT) {
+      if (jsToNativeBridgeMode == jsToNativeModes.LOCATION_CHANGE) {
+          window.location = 'http://cdv_exec/' + service + '#' + action + '#' + callbackId + '#' + argsJson; 
+      } else if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT) {
           // Explicit cast to string is required on Android 2.1 to convert from
           // a Java string to a JS string.
           result = '' + _cordovaExec.exec(service, action, callbackId, argsJson);
@@ -70,7 +75,7 @@ function androidExec(success, fail, service, action, args) {
       }
 
       // If a result was returned
-      if (result.length > 0) {
+      if (result) {
           var v = JSON.parse(result);
 
           // If status is OK, then return value back to caller