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/24 20:32:18 UTC

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

Updated Branches:
  refs/heads/master aa1380d84 -> cc3e4d591


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

Branch: refs/heads/master
Commit: cc3e4d5915e3138ade6dcdcb9a8f2cd22160e5ec
Parents: aa1380d
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Aug 24 14:05:10 2012 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Aug 24 14:19:13 2012 -0400

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


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/cc3e4d59/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