Browse Source

加强判断

Pq 1 year ago
parent
commit
e6887882d5

+ 9 - 1
student/src/main/java/com/cooleshow/student/ui/web/HtmlActivity.java

@@ -1218,7 +1218,15 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
         @Override
         public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
             super.onReceivedError(view, request, error);
-            showLoadErrorView();
+            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) {
+                        showLoadErrorView();
+                    }
+                }
+            }
         }
 
     }

+ 9 - 1
teacher/src/main/java/com/cooleshow/teacher/ui/web/HtmlActivity.java

@@ -1228,7 +1228,15 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
         @Override
         public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
             super.onReceivedError(view, request, error);
-            showLoadErrorView();
+            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) {
+                        showLoadErrorView();
+                    }
+                }
+            }
         }
     }