Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C0CE710D23 for ; Tue, 4 Feb 2014 05:13:52 +0000 (UTC) Received: (qmail 50611 invoked by uid 500); 4 Feb 2014 05:13:52 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 50600 invoked by uid 500); 4 Feb 2014 05:13:50 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 50593 invoked by uid 99); 4 Feb 2014 05:13:48 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Feb 2014 05:13:48 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 33A013144A3; Tue, 4 Feb 2014 05:13:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: android commit: Ignore multiple onPageFinished() callbacks & onReceivedError due to stopLoading() Date: Tue, 4 Feb 2014 05:13:48 +0000 (UTC) Updated Branches: refs/heads/master dfae37421 -> a5c8472a3 Ignore multiple onPageFinished() callbacks & onReceivedError due to stopLoading() I believe this happens only when using custom schemes. Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/a5c8472a Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/a5c8472a Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/a5c8472a Branch: refs/heads/master Commit: a5c8472a374c1c2b2026fa9dbb39235e198768ef Parents: dfae374 Author: Andrew Grieve Authored: Tue Feb 4 00:12:11 2014 -0500 Committer: Andrew Grieve Committed: Tue Feb 4 00:12:11 2014 -0500 ---------------------------------------------------------------------- framework/src/org/apache/cordova/CordovaWebView.java | 5 +++++ .../src/org/apache/cordova/CordovaWebViewClient.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a5c8472a/framework/src/org/apache/cordova/CordovaWebView.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index b30ea78..b0e3d43 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -541,6 +541,11 @@ public class CordovaWebView extends WebView { this.loadUrlIntoView(url); } + @Override + public void stopLoading() { + viewClient.isCurrentlyLoading = false; + super.stopLoading(); + } public void onScrollChanged(int l, int t, int oldl, int oldt) { http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a5c8472a/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 e465ffa..0b7b800 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -62,6 +62,7 @@ public class CordovaWebViewClient extends WebViewClient { CordovaInterface cordova; CordovaWebView appView; private boolean doClearHistory = false; + private boolean isCurrentlyLoading; /** The authorization tokens. */ private Hashtable authenticationTokens = new Hashtable(); @@ -266,7 +267,9 @@ public class CordovaWebViewClient extends WebViewClient { */ @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { - + super.onPageStarted(view, url, favicon); + isCurrentlyLoading = true; + LOG.d(TAG, "onPageStarted(" + url + ")"); // Flush stale messages. this.appView.jsMessageQueue.reset(); @@ -290,6 +293,11 @@ public class CordovaWebViewClient extends WebViewClient { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); + // Ignore excessive calls. + if (!isCurrentlyLoading) { + return; + } + isCurrentlyLoading = false; LOG.d(TAG, "onPageFinished(" + url + ")"); /** @@ -344,6 +352,10 @@ public class CordovaWebViewClient extends WebViewClient { */ @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { + // Ignore error due to stopLoading(). + if (!isCurrentlyLoading) { + return; + } LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl); // Clear timeout flag