cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [10/17] git commit: Added a reload function.
Date Sat, 25 Oct 2014 01:26:28 GMT
Added a reload function.


Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/da46492f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/da46492f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/da46492f

Branch: refs/heads/master
Commit: da46492fc073c16858f42d1bbe6625f6c7b646a5
Parents: bc764cb
Author: Max Woghiren <max.woghiren@gmail.com>
Authored: Mon Oct 6 15:26:33 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri Oct 24 21:26:07 2014 -0400

----------------------------------------------------------------------
 AppHarnessUI/AppHarnessUI.m            |  8 ++++++++
 AppHarnessUI/android/AppHarnessUI.java | 21 +++++++++++++++++++++
 AppHarnessUI/appharnessui.js           |  4 ++++
 www/cdvah/js/AppHarnessUI.js           |  5 +++++
 4 files changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/AppHarnessUI/AppHarnessUI.m
----------------------------------------------------------------------
diff --git a/AppHarnessUI/AppHarnessUI.m b/AppHarnessUI/AppHarnessUI.m
index 3d7dafc..f795061 100644
--- a/AppHarnessUI/AppHarnessUI.m
+++ b/AppHarnessUI/AppHarnessUI.m
@@ -128,6 +128,14 @@
     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
 }
 
+- (void)reload:(CDVInvokedUrlCommand*)command {
+    if (_slaveCordovaViewController == nil) {
+        NSLog(@"AppHarnessUI.reload: no url to reload");
+    } else {
+        [[_slaveCordovaViewController webView] reload];
+    }
+}
+
 - (void)destroy:(CDVInvokedUrlCommand*)command {
     if (_slaveCordovaViewController == nil) {
         NSLog(@"AppHarnessUI.destroy: already destroyed.");

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/AppHarnessUI/android/AppHarnessUI.java
----------------------------------------------------------------------
diff --git a/AppHarnessUI/android/AppHarnessUI.java b/AppHarnessUI/android/AppHarnessUI.java
index f5dadc5..7ca74a2 100644
--- a/AppHarnessUI/android/AppHarnessUI.java
+++ b/AppHarnessUI/android/AppHarnessUI.java
@@ -53,6 +53,7 @@ public class AppHarnessUI extends CordovaPlugin {
     boolean slaveVisible;
     CallbackContext eventsCallback;
     LinearLayoutSoftKeyboardDetect layoutView;
+    String startUrl;
 
     public boolean isSlaveVisible() {
         return slaveVisible;
@@ -76,6 +77,12 @@ public class AppHarnessUI extends CordovaPlugin {
                     create(url, pluginIdWhitelistAsSet, callbackContext);
                 }
             });
+        } else if ("reload".equals(action)) {
+            this.cordova.getActivity().runOnUiThread(new Runnable() {
+                public void run() {
+                    reload(callbackContext);
+                }
+            });
         } else if ("destroy".equals(action)) {
             this.cordova.getActivity().runOnUiThread(new Runnable() {
                 public void run() {
@@ -122,6 +129,7 @@ public class AppHarnessUI extends CordovaPlugin {
     }
 
     private void create(String url, Set<String> pluginIdWhitelist, CallbackContext
callbackContext) {
+        startUrl = url;
         CordovaActivity activity = (CordovaActivity)cordova.getActivity();
 
         if (slaveWebView != null) {
@@ -149,6 +157,18 @@ public class AppHarnessUI extends CordovaPlugin {
         callbackContext.success();
     }
 
+    private void reload(CallbackContext callbackContext) {
+        if (slaveWebView == null) {
+            Log.w(LOG_TAG, "reload: no webview exists");
+        } else if (startUrl == null) {
+            Log.w(LOG_TAG, "reload: no recorded start url");
+        } else {
+            slaveWebView.clearCache(true);
+            slaveWebView.loadUrl(startUrl);
+        }
+        callbackContext.success();
+    }
+
     private void destroy(CallbackContext callbackContext) {
         if (slaveWebView == null) {
             Log.w(LOG_TAG, "destroy: already destroyed");
@@ -162,6 +182,7 @@ public class AppHarnessUI extends CordovaPlugin {
             slaveWebView.getView().setScaleY(1.0f);
             slaveWebView.setStealTapEvents(false);
             slaveVisible = false;
+            startUrl = null;
             sendEvent("destroyed");
         }
         if (eventsCallback != null) {

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/AppHarnessUI/appharnessui.js
----------------------------------------------------------------------
diff --git a/AppHarnessUI/appharnessui.js b/AppHarnessUI/appharnessui.js
index db46720..7335ffb 100644
--- a/AppHarnessUI/appharnessui.js
+++ b/AppHarnessUI/appharnessui.js
@@ -30,6 +30,10 @@ exports.create = function(url, serviceNameWhitelist, win) {
     exec(win, null, 'AppHarnessUI', 'create', [url, serviceNameWhitelist]);
 };
 
+exports.reload = function(win) {
+    exec(win, null, 'AppHarnessUI', 'reload', []);
+}
+
 exports.destroy = function(win) {
     exec(win, null, 'AppHarnessUI', 'destroy', []);
 };

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/da46492f/www/cdvah/js/AppHarnessUI.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/AppHarnessUI.js b/www/cdvah/js/AppHarnessUI.js
index dfd84c7..5137c83 100644
--- a/www/cdvah/js/AppHarnessUI.js
+++ b/www/cdvah/js/AppHarnessUI.js
@@ -49,6 +49,11 @@
                 cordova.plugins.appharnessui.destroy(deferred.resolve);
                 return deferred.promise;
             },
+            reload: function() {
+                var deferred = $q.defer();
+                cordova.plugins.appharnessui.reload(deferred.resolve);
+                return deferred.promise;
+            },
             setVisible: function(value) {
                 var deferred = $q.defer();
                 cordova.plugins.appharnessui.setVisible(value, deferred.resolve);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message