mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
Ignore multiple onPageFinished() callbacks & onReceivedError due to stopLoading()
I believe this happens only when using custom schemes.
This commit is contained in:
parent
dfae37421d
commit
a5c8472a37
@ -541,6 +541,11 @@ public class CordovaWebView extends WebView {
|
|||||||
this.loadUrlIntoView(url);
|
this.loadUrlIntoView(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopLoading() {
|
||||||
|
viewClient.isCurrentlyLoading = false;
|
||||||
|
super.stopLoading();
|
||||||
|
}
|
||||||
|
|
||||||
public void onScrollChanged(int l, int t, int oldl, int oldt)
|
public void onScrollChanged(int l, int t, int oldl, int oldt)
|
||||||
{
|
{
|
||||||
|
@ -62,6 +62,7 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
CordovaInterface cordova;
|
CordovaInterface cordova;
|
||||||
CordovaWebView appView;
|
CordovaWebView appView;
|
||||||
private boolean doClearHistory = false;
|
private boolean doClearHistory = false;
|
||||||
|
private boolean isCurrentlyLoading;
|
||||||
|
|
||||||
/** The authorization tokens. */
|
/** The authorization tokens. */
|
||||||
private Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<String, AuthenticationToken>();
|
private Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<String, AuthenticationToken>();
|
||||||
@ -266,7 +267,9 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||||
|
super.onPageStarted(view, url, favicon);
|
||||||
|
isCurrentlyLoading = true;
|
||||||
|
LOG.d(TAG, "onPageStarted(" + url + ")");
|
||||||
// Flush stale messages.
|
// Flush stale messages.
|
||||||
this.appView.jsMessageQueue.reset();
|
this.appView.jsMessageQueue.reset();
|
||||||
|
|
||||||
@ -290,6 +293,11 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
|
// Ignore excessive calls.
|
||||||
|
if (!isCurrentlyLoading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isCurrentlyLoading = false;
|
||||||
LOG.d(TAG, "onPageFinished(" + url + ")");
|
LOG.d(TAG, "onPageFinished(" + url + ")");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -344,6 +352,10 @@ public class CordovaWebViewClient extends WebViewClient {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
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);
|
LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);
|
||||||
|
|
||||||
// Clear timeout flag
|
// Clear timeout flag
|
||||||
|
Loading…
Reference in New Issue
Block a user