From 267d07f3a585916b3949c88579a0d3a34c65045d Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 17 Nov 2022 11:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E9=A1=B5=E5=8A=A0=E8=BD=BD=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=E7=BD=91=E5=9D=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.gradle | 4 ++-- .../live/activity/ZhuangBanActivity.java | 22 ++++++++++++++++++- .../live/dialog/LiveHDDialogFragment.java | 16 ++++++++++++++ .../res/layout/activity_zhuang_ban_new.xml | 18 ++++++++++----- live/src/main/res/layout/dialog_live_hd.xml | 6 +++++ 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/config.gradle b/config.gradle index 74c89ff01..8affa5db3 100644 --- a/config.gradle +++ b/config.gradle @@ -10,9 +10,9 @@ ext { 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", diff --git a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java index 2eaab3ec1..fd28414ab 100644 --- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java @@ -16,6 +16,8 @@ import android.view.View; import android.view.ViewGroup; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; +import android.webkit.WebResourceRequest; +import android.webkit.WebResourceResponse; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -66,7 +68,7 @@ public class ZhuangBanActivity extends AbsActivity { private ValueCallback mValueCallback2; private SVGAImageView svga; private FrameLayout title; - private TextView titleView; + private TextView titleView, htmlError; private RelativeLayout rootView; @Override @@ -84,6 +86,7 @@ public class ZhuangBanActivity extends AbsActivity { mProgressBar = (ProgressBar) findViewById(R.id.progressbar); svga = (SVGAImageView) findViewById(R.id.svga); titleView = (TextView) findViewById(R.id.titleView); + htmlError = (TextView) findViewById(R.id.html_error); title = findViewById(R.id.ft_title); if (isFullWindow) { title.setVisibility(View.GONE); @@ -136,6 +139,23 @@ public class ZhuangBanActivity extends AbsActivity { public void onPageFinished(WebView view, String url) { 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() { @Override diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index 2a0ac1ef4..09d74fe4f 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -16,10 +16,13 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowInsets; import android.view.WindowManager; +import android.webkit.WebResourceRequest; +import android.webkit.WebResourceResponse; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.LinearLayout; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -59,6 +62,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { private boolean isFullWindow = false; private String roomId; private DialogInterface.OnShowListener listener; + private TextView htmlError; public LiveHDDialogFragment() { @@ -140,6 +144,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mWebView = (WebView) findViewById(R.id.rlWebview); + htmlError = (TextView) findViewById(R.id.html_error); findViewById(R.id.btn_back).setOnClickListener(v -> dismiss()); mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(getActivity(), mWebView) .setLiveZhuangBana(true). @@ -197,6 +202,17 @@ public class LiveHDDialogFragment extends AbsDialogFragment { 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { diff --git a/live/src/main/res/layout/activity_zhuang_ban_new.xml b/live/src/main/res/layout/activity_zhuang_ban_new.xml index 21876d17b..159c7a5c5 100644 --- a/live/src/main/res/layout/activity_zhuang_ban_new.xml +++ b/live/src/main/res/layout/activity_zhuang_ban_new.xml @@ -8,9 +8,9 @@ android:id="@+id/ft_title" android:layout_width="match_parent" android:layout_height="65dp" - android:visibility="visible" android:background="@color/white" - android:paddingTop="19dp"> + android:paddingTop="19dp" + android:visibility="visible"> + + + android:progressDrawable="@drawable/bg_horizontal_progressbar" /> + android:layout_height="match_parent" + android:orientation="vertical" /> + android:layout_gravity="center_vertical" /> diff --git a/live/src/main/res/layout/dialog_live_hd.xml b/live/src/main/res/layout/dialog_live_hd.xml index 863587c0f..125574475 100644 --- a/live/src/main/res/layout/dialog_live_hd.xml +++ b/live/src/main/res/layout/dialog_live_hd.xml @@ -51,6 +51,12 @@ + +