网页加载错误显示错误网址问题
This commit is contained in:
parent
977bfa910c
commit
267d07f3a5
@ -10,9 +10,9 @@ ext {
|
|||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
//正式
|
//正式
|
||||||
|
|
||||||
// serverHost : "https://napi.yaoulive.com",
|
serverHost : "https://napi.yaoulive.com",
|
||||||
//測試
|
//測試
|
||||||
serverHost : "https://ceshi.yaoulive.com",
|
// serverHost : "https://ceshi.yaoulive.com",
|
||||||
|
|
||||||
//腾讯地图
|
//腾讯地图
|
||||||
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",
|
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",
|
||||||
|
@ -16,6 +16,8 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebResourceResponse;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
@ -66,7 +68,7 @@ public class ZhuangBanActivity extends AbsActivity {
|
|||||||
private ValueCallback<Uri[]> mValueCallback2;
|
private ValueCallback<Uri[]> mValueCallback2;
|
||||||
private SVGAImageView svga;
|
private SVGAImageView svga;
|
||||||
private FrameLayout title;
|
private FrameLayout title;
|
||||||
private TextView titleView;
|
private TextView titleView, htmlError;
|
||||||
private RelativeLayout rootView;
|
private RelativeLayout rootView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,6 +86,7 @@ public class ZhuangBanActivity extends AbsActivity {
|
|||||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||||
svga = (SVGAImageView) findViewById(R.id.svga);
|
svga = (SVGAImageView) findViewById(R.id.svga);
|
||||||
titleView = (TextView) findViewById(R.id.titleView);
|
titleView = (TextView) findViewById(R.id.titleView);
|
||||||
|
htmlError = (TextView) findViewById(R.id.html_error);
|
||||||
title = findViewById(R.id.ft_title);
|
title = findViewById(R.id.ft_title);
|
||||||
if (isFullWindow) {
|
if (isFullWindow) {
|
||||||
title.setVisibility(View.GONE);
|
title.setVisibility(View.GONE);
|
||||||
@ -136,6 +139,23 @@ public class ZhuangBanActivity extends AbsActivity {
|
|||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
setTitle(view.getTitle());
|
setTitle(view.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||||
|
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||||
|
super.onReceivedHttpError(view, request, errorResponse);
|
||||||
|
// 这个方法在6.0才出现
|
||||||
|
int statusCode = errorResponse.getStatusCode();
|
||||||
|
if (404 == statusCode || 500 == statusCode) {
|
||||||
|
htmlError.setVisibility(View.VISIBLE);
|
||||||
|
htmlError.setText("errorCode:" + statusCode +"\n failingUrl:" + request.getUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,10 +16,13 @@ import android.view.ViewGroup;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebResourceResponse;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -59,6 +62,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
|||||||
private boolean isFullWindow = false;
|
private boolean isFullWindow = false;
|
||||||
private String roomId;
|
private String roomId;
|
||||||
private DialogInterface.OnShowListener listener;
|
private DialogInterface.OnShowListener listener;
|
||||||
|
private TextView htmlError;
|
||||||
|
|
||||||
public LiveHDDialogFragment() {
|
public LiveHDDialogFragment() {
|
||||||
|
|
||||||
@ -140,6 +144,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
|||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
mWebView = (WebView) findViewById(R.id.rlWebview);
|
mWebView = (WebView) findViewById(R.id.rlWebview);
|
||||||
|
htmlError = (TextView) findViewById(R.id.html_error);
|
||||||
findViewById(R.id.btn_back).setOnClickListener(v -> dismiss());
|
findViewById(R.id.btn_back).setOnClickListener(v -> dismiss());
|
||||||
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(getActivity(), mWebView)
|
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(getActivity(), mWebView)
|
||||||
.setLiveZhuangBana(true).
|
.setLiveZhuangBana(true).
|
||||||
@ -197,6 +202,17 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
|||||||
listener = null;
|
listener = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||||
|
super.onReceivedHttpError(view, request, errorResponse);
|
||||||
|
// 这个方法在6.0才出现
|
||||||
|
int statusCode = errorResponse.getStatusCode();
|
||||||
|
if (404 == statusCode || 500 == statusCode) {
|
||||||
|
htmlError.setVisibility(View.VISIBLE);
|
||||||
|
htmlError.setText("errorCode:" + statusCode +"\n failingUrl:" + request.getUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (bundle.getBoolean("banScrollY", false)) {
|
if (bundle.getBoolean("banScrollY", false)) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
android:id="@+id/ft_title"
|
android:id="@+id/ft_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="65dp"
|
android:layout_height="65dp"
|
||||||
android:visibility="visible"
|
|
||||||
android:background="@color/white"
|
android:background="@color/white"
|
||||||
android:paddingTop="19dp">
|
android:paddingTop="19dp"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -39,6 +39,12 @@
|
|||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/html_error"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/root_view"
|
android:id="@+id/root_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -49,20 +55,20 @@
|
|||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="3dp"
|
android:layout_height="3dp"
|
||||||
android:progressDrawable="@drawable/bg_horizontal_progressbar"/>
|
android:progressDrawable="@drawable/bg_horizontal_progressbar" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
|
||||||
android:id="@+id/rootView"
|
android:id="@+id/rootView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
|
||||||
<com.opensource.svgaplayer.SVGAImageView
|
<com.opensource.svgaplayer.SVGAImageView
|
||||||
android:id="@+id/svga"
|
android:id="@+id/svga"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"/>
|
android:layout_gravity="center_vertical" />
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -51,6 +51,12 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/html_error"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/rlWebview"
|
android:id="@+id/rlWebview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user