cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [08/17] git commit: Stopped destroying the webview on every launch.
Date Sat, 25 Oct 2014 01:26:26 GMT
Stopped destroying the webview on every launch.

If we're relaunching the same app, we reload the webview.  This handles the most annoying
`cca push --watch` case.
If a new app is being launched, though, the webview is still destroyed and recreated (for
now).


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

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

----------------------------------------------------------------------
 www/cdvah/js/AppsService.js | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/7c884d15/www/cdvah/js/AppsService.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/AppsService.js b/www/cdvah/js/AppsService.js
index 14b8c5c..9c25391 100644
--- a/www/cdvah/js/AppsService.js
+++ b/www/cdvah/js/AppsService.js
@@ -139,8 +139,21 @@
             },
 
             launchApp : function(installer) {
-                return AppsService.quitApp()
+                // Determine whether we're relaunching the same app as is already active.
+                var relaunch = activeInstaller && activeInstaller.appId;
+                relaunch = installer && installer.appId;
+                relaunch = relaunch && (activeInstaller.appId === installer.appId);
+
+                return $q.when()
                 .then(function() {
+                    // If we're relaunching the active app, move on.
+                    // Otherwise, quit the active app.
+                    if (relaunch) {
+                        return $q.when();
+                    } else {
+                        return AppsService.quitApp();
+                    }
+                }).then(function() {
                     activeInstaller = installer;
                     return installer.launch();
                 }).then(function(launchUrl) {
@@ -152,7 +165,14 @@
                         return installer.getPluginMetadata();
                     }).then(function(pluginMetadata) {
                         $location.path('/inappmenu');
-                        return AppHarnessUI.create(launchUrl, pluginMetadata);
+                        // If we're relaunching the active app, just reload the existing
webview.
+                        // Otherwise, create a new one.
+                        // TODO(maxw): Use the existing webview all the time.
+                        if (relaunch) {
+                            return AppHarnessUI.reload();
+                        } else {
+                            return AppHarnessUI.create(launchUrl, pluginMetadata);
+                        }
                     }).then(function() {
                         if (AppsService.onAppListChange) {
                             AppsService.onAppListChange();


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


Mime
View raw message