From a9d323354b75adae63c66b1b2fa81b4084f5b5dd Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 21 Nov 2022 15:22:54 +0800 Subject: [PATCH] =?UTF-8?q?Js=E6=8E=A5=E5=8F=A3=E6=95=B4=E5=90=88=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/JavascriptInterfaceUtils.java | 31 ++++++++++++------- config.gradle | 4 +-- .../live/activity/ZhuangBanActivity.java | 7 ++--- .../main/activity/ZhuangBanActivity.java | 11 +++++-- .../main/res/layout/activity_zhuang_ban.xml | 2 ++ 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index a1a3200a4..43d876ad7 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -64,14 +64,13 @@ public class JavascriptInterfaceUtils { } public static JavascriptInterfaceUtils getInstance() { - if (sInstance == null) { - synchronized (CityUtil.class) { - if (sInstance == null) { - sInstance = new JavascriptInterfaceUtils(); - } - } + + synchronized (JavascriptInterfaceUtils.class) { + + sInstance = new JavascriptInterfaceUtils(); + + return sInstance; } - return sInstance; } @@ -117,8 +116,13 @@ public class JavascriptInterfaceUtils { @JavascriptInterface public void androidClickToNewH5PageView(String url) { url = CommonAppConfig.HOST + url; - url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" - + CommonAppConfig.getInstance().getToken(); + if (url.contains("?")) { + url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + + CommonAppConfig.getInstance().getToken(); + } else { + url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + + CommonAppConfig.getInstance().getToken(); + } if (LiveZhuangBana) { RouteUtil.forwardLiveZhuangBanActivity(url, false); } else { @@ -135,8 +139,13 @@ public class JavascriptInterfaceUtils { @JavascriptInterface public void androidClickToNewH5PageView(String url, String title) { url = CommonAppConfig.HOST + url; - url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" - + CommonAppConfig.getInstance().getToken(); + if (url.contains("?")) { + url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + + CommonAppConfig.getInstance().getToken(); + } else { + url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + + CommonAppConfig.getInstance().getToken(); + } if (LiveZhuangBana) { RouteUtil.forwardLiveZhuangBanActivity(url, title); } else { diff --git a/config.gradle b/config.gradle index 9b9ac5933..d73f7bbfa 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 f5fc8f859..b0370cf04 100644 --- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java @@ -97,9 +97,6 @@ public class ZhuangBanActivity extends AbsActivity { } else { if (TextUtils.equals(titleString, "blank")) { title.setVisibility(View.GONE); - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) rootView.getLayoutParams(); - params.topMargin = DpUtil.dp2px(24); - rootView.setLayoutParams(params); } else { title.setVisibility(View.VISIBLE); titleView.setText(titleString); @@ -152,9 +149,9 @@ public class ZhuangBanActivity extends AbsActivity { // 这个方法在6.0才出现 int statusCode = errorResponse.getStatusCode(); if (404 == statusCode || 500 == statusCode) { - if ( !request.getUrl().toString().contains("favicon")){ + if (!request.getUrl().toString().contains("favicon")) { htmlError.setVisibility(View.VISIBLE); - htmlError.setText("errorCode:" + statusCode +"\n failingUrl:" + request.getUrl()); + htmlError.setText("errorCode:" + statusCode + "\n failingUrl:" + request.getUrl()); } } } diff --git a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java index eabfcd4c7..00a9b4629 100644 --- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java +++ b/main/src/main/java/com/yunbao/main/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; @@ -83,9 +85,6 @@ public class ZhuangBanActivity extends AbsActivity { lt_title = (LinearLayout) findViewById(R.id.lt_title); LinearLayout rootView = (LinearLayout) findViewById(com.yunbao.live.R.id.rootView); if (getIntent().hasExtra("title")) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) rootView.getLayoutParams(); - params.topMargin = DpUtil.dp2px(34); - rootView.setLayoutParams(params); if (TextUtils.isEmpty(titleString)) { lt_title.setVisibility(View.GONE); } else { @@ -129,7 +128,13 @@ public class ZhuangBanActivity extends AbsActivity { } else { setTitle(titleString); } + int height = view.getMeasuredHeight(); + Log.e("网页高度", height + ""); + } + @Override + public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { + super.onReceivedHttpError(view, request, errorResponse); } }); mWebView.setWebChromeClient(new WebChromeClient() { diff --git a/main/src/main/res/layout/activity_zhuang_ban.xml b/main/src/main/res/layout/activity_zhuang_ban.xml index e9e2cdbbb..8373ab469 100644 --- a/main/src/main/res/layout/activity_zhuang_ban.xml +++ b/main/src/main/res/layout/activity_zhuang_ban.xml @@ -21,6 +21,7 @@