incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject [14/16] android commit: changing JS invoked from native to work with modular js
Date Fri, 17 Feb 2012 22:58:02 GMT
changing JS invoked from native to work with modular js


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

Branch: refs/heads/master
Commit: 52213541a375d5f43a4d554900f821acfe02687b
Parents: c7d4d83
Author: Fil Maj <filip.maj@nitobi.com>
Authored: Wed Jan 25 14:28:47 2012 -0800
Committer: Fil Maj <filip.maj@nitobi.com>
Committed: Wed Feb 15 10:37:24 2012 -0800

----------------------------------------------------------------------
 .../org/apache/cordova/CordovaWebViewClient.java   |    2 +-
 framework/src/org/apache/cordova/DroidGap.java     |   12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/52213541/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index 4946cc4..319a944 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -218,7 +218,7 @@ public class CordovaWebViewClient extends WebViewClient {
         // not loaded yet then just set a flag so that the onNativeReady can be fired
         // from the JS side when the JS gets to that code.
         if (!url.equals("about:blank")) {
-            ctx.appView.loadUrl("javascript:try{ Cordova.onNativeReady.fire();}catch(e){_nativeReady
= true;}");
+            ctx.appView.loadUrl("javascript:try{ require('cordova/channel').onNativeReady.fire();}catch(e){_nativeReady
= true;}");
         }
 
         // Make app visible after 2 sec in case there was a JS error and Cordova JS never
initialized correctly

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/52213541/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 61aba0d..d326e95 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -847,7 +847,7 @@ public class DroidGap extends CordovaInterface {
         }
 
         // Send pause event to JavaScript
-        this.appView.loadUrl("javascript:try{Cordova.fireDocumentEvent('pause');}catch(e){};");
+        this.appView.loadUrl("javascript:try{require('cordova/channel').onPause.fire();}catch(e){console.log('exception
firing pause event from native');};");
 
         // Forward to plugins
         this.pluginManager.onPause(this.keepRunning);
@@ -888,7 +888,7 @@ public class DroidGap extends CordovaInterface {
         }
 
         // Send resume event to JavaScript
-        this.appView.loadUrl("javascript:try{Cordova.fireDocumentEvent('resume');}catch(e){};");
+        this.appView.loadUrl("javascript:try{require('cordova/channel').onResume.fire();}catch(e){console.log('exception
firing resume event from native');};");
 
         // Forward to plugins
         this.pluginManager.onResume(this.keepRunning || this.activityResultKeepRunning);
@@ -918,7 +918,7 @@ public class DroidGap extends CordovaInterface {
 
 
             // Send destroy event to JavaScript
-            this.appView.loadUrl("javascript:try{Cordova.onDestroy.fire();}catch(e){};");
+            this.appView.loadUrl("javascript:try{require('cordova/channel').onDestroy.fire();}catch(e){console.log('exception
firing destroy event from native');};");
 
             // Load blank page so that JavaScript onunload is called
             this.appView.loadUrl("about:blank");
@@ -1080,7 +1080,7 @@ public class DroidGap extends CordovaInterface {
 
             // If back key is bound, then send event to JavaScript
             if (this.bound) {
-                this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('backbutton');");
+                this.appView.loadUrl("javascript:require('cordova').fireDocumentEvent('backbutton');");
                 return true;
             }
 
@@ -1102,13 +1102,13 @@ public class DroidGap extends CordovaInterface {
 
         // If menu key
         else if (keyCode == KeyEvent.KEYCODE_MENU) {
-            this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('menubutton');");
+            this.appView.loadUrl("javascript:require('cordova').fireDocumentEvent('menubutton');");
             return super.onKeyDown(keyCode, event);
         }
 
         // If search key
         else if (keyCode == KeyEvent.KEYCODE_SEARCH) {
-            this.appView.loadUrl("javascript:Cordova.fireDocumentEvent('searchbutton');");
+            this.appView.loadUrl("javascript:require('cordova').fireDocumentEvent('searchbutton');");
             return true;
         }
 


Mime
View raw message