incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From macdo...@apache.org
Subject git commit: Fixing a timing issue with the web view history not being cleared properly
Date Fri, 27 Jan 2012 17:02:52 GMT
Updated Branches:
  refs/heads/master 6e82ec415 -> 4f6153142


Fixing a timing issue with the web view history not being cleared properly


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

Branch: refs/heads/master
Commit: 4f61531422147cfe4a8fa09bb37f8f2e77a73c2d
Parents: 6e82ec4
Author: macdonst <simon.macdonald@gmail.com>
Authored: Fri Jan 27 12:02:31 2012 -0500
Committer: macdonst <simon.macdonald@gmail.com>
Committed: Fri Jan 27 12:02:31 2012 -0500

----------------------------------------------------------------------
 .../src/com/phonegap/CordovaWebViewClient.java     |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/4f615314/framework/src/com/phonegap/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/CordovaWebViewClient.java b/framework/src/com/phonegap/CordovaWebViewClient.java
index bf7233e..fbb1f9f 100755
--- a/framework/src/com/phonegap/CordovaWebViewClient.java
+++ b/framework/src/com/phonegap/CordovaWebViewClient.java
@@ -27,6 +27,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
 import android.graphics.Bitmap;
 import android.net.Uri;
 import android.net.http.SslError;
+import android.util.Log;
 import android.view.View;
 import android.webkit.HttpAuthHandler;
 import android.webkit.SslErrorHandler;
@@ -40,6 +41,7 @@ public class CordovaWebViewClient extends WebViewClient {
     
     private static final String TAG = "Cordova";
     DroidGap ctx;
+    private boolean doClearHistory = false;
 
     /**
      * Constructor.
@@ -185,6 +187,7 @@ public class CordovaWebViewClient extends WebViewClient {
         // Clear history so history.back() doesn't do anything.  
         // So we can reinit() native side CallbackServer & PluginManager.
         view.clearHistory(); 
+        this.doClearHistory = true;
     }
     
     /**
@@ -197,6 +200,17 @@ public class CordovaWebViewClient extends WebViewClient {
     public void onPageFinished(WebView view, String url) {
         super.onPageFinished(view, url);
 
+        /**
+         * Because of a timing issue we need to clear this history in onPageFinished as well
as 
+         * onPageStarted. However we only want to do this if the doClearHistory boolean is
set to 
+         * true. You see when you load a url with a # in it which is common in jQuery applications
+         * onPageStared is not called. Clearing the history at that point would break jQuery
apps.
+         */
+        if (this.doClearHistory) {
+            view.clearHistory();
+            this.doClearHistory = false;
+        }
+
         // Clear timeout flag
         this.ctx.loadUrlTimeout++;
 


Mime
View raw message