|
@@ -178,6 +178,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
private boolean isNeedResetScreenOrientation = true;
|
|
|
private boolean isResetOrientation = false;
|
|
|
private boolean isLoadError = false;
|
|
|
+ private boolean isLoadCompleted = false;
|
|
|
private DownloadHelper.OnEventListener saveFileListener;
|
|
|
|
|
|
private DownloadHelper.OnEventListener mEventListener;
|
|
@@ -1190,6 +1191,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
super.onPageStarted(view, url, favicon);
|
|
|
isLoadError = false;
|
|
|
+ isLoadCompleted = false;
|
|
|
}
|
|
|
|
|
|
//页面载入结束时调用
|
|
@@ -1198,6 +1200,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
super.onPageFinished(view, url);
|
|
|
if (!isLoadError) {
|
|
|
showWebView();
|
|
|
+ isLoadCompleted =true;
|
|
|
}
|
|
|
if (!TextUtils.isEmpty(authorization)) {
|
|
|
String js = "window.localStorage.setItem('Authorization','" + authorization + "');";
|
|
@@ -1255,15 +1258,20 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
|
|
|
//处理报错信息
|
|
|
@Override
|
|
|
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
|
|
- super.onReceivedError(view, request, error);
|
|
|
+// super.onReceivedError(view, request, error);
|
|
|
if (error != null) {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
|
LOG.i("onReceivedError:" + error.getErrorCode());
|
|
|
LOG.i("onReceivedError:" + error.getDescription());
|
|
|
- if (error.getErrorCode() == WebViewClient.ERROR_HOST_LOOKUP || error.getErrorCode() == WebViewClient.ERROR_CONNECT) {
|
|
|
+ int errorCode = error.getErrorCode();
|
|
|
+ if (errorCode== WebViewClient.ERROR_HOST_LOOKUP || errorCode == WebViewClient.ERROR_CONNECT || errorCode == WebViewClient.ERROR_PROXY_AUTHENTICATION) {
|
|
|
+ if (isLoadCompleted) {
|
|
|
+ //20240827同步加载完后的error不需要显示 错误页
|
|
|
+ return;
|
|
|
+ }
|
|
|
showLoadErrorView();
|
|
|
} else {
|
|
|
- if (error.getErrorCode() == WebViewClient.ERROR_UNKNOWN) {
|
|
|
+ if(error.getErrorCode() == WebViewClient.ERROR_UNKNOWN) {
|
|
|
return;
|
|
|
}
|
|
|
String errorMsg = "url:" + request.getUrl().toString() + " " + error.getDescription();
|