diff --git a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java index 4f4b73be4..638334d48 100644 --- a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java +++ b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java @@ -119,10 +119,10 @@ public class OpenAdModel extends BaseModel { } public String getUrl() { - if (!url.startsWith("http://") || !url.startsWith("https://")) { + if (!url.startsWith("http://") && !url.startsWith("https://")) { url = CommonAppConfig.HOST + (url.startsWith("/") ? url : "/" + url); } - return url + "?t=" + System.currentTimeMillis() / 1000; + return url; } public String getOriginalUrl() { diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java index 24771384d..e878da2d2 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java @@ -3,6 +3,7 @@ package com.yunbao.common.dialog; import android.app.Activity; import android.content.Context; import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.LinearLayout; @@ -18,6 +19,7 @@ import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.JavascriptInterfaceUtils; +import com.yunbao.common.utils.L; import com.yunbao.common.utils.ScreenDimenUtil; import org.greenrobot.eventbus.Subscribe; @@ -95,6 +97,19 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow { mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件 mWebView.setHorizontalScrollBarEnabled(false); mWebView.setVerticalScrollBarEnabled(false); + mWebView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + L.e("H5-------->" + url); + view.loadUrl(url); + + return true; + } + + @Override + public void onPageFinished(WebView view, String url) { + } + }); String url=model.getUrl(); if(url.contains("?")){ url+="&uid="+ IMLoginManager.get(mContext).getUserInfo().getId()+"&token="+IMLoginManager.get(mContext).getUserInfo().getToken(); diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java index ed474af5f..3f6211eea 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java @@ -5,9 +5,12 @@ import android.content.Context; import android.graphics.Color; import android.util.Log; import android.view.View; +import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.WindowInsets; +import android.webkit.WebResourceRequest; import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.LinearLayout; @@ -24,8 +27,10 @@ import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.JavascriptInterfaceUtils; +import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ScreenDimenUtil; +import com.yunbao.common.utils.ToastUtil; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -126,7 +131,7 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { private void setWeb(OpenAdModel model, int width, int height) { WebView mWebView = new WebView(mContext); - mWebView.setLayoutParams(new LinearLayout.LayoutParams(width, height)); + mWebView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height)); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptEnabled(true); @@ -138,6 +143,19 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow { mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件 mWebView.setHorizontalScrollBarEnabled(false); mWebView.setVerticalScrollBarEnabled(false); + mWebView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + L.e("H5-------->" + url); + view.loadUrl(url); + + return true; + } + + @Override + public void onPageFinished(WebView view, String url) { + } + }); String url = model.getUrl(); if (url.contains("?")) { url += "&uid=" + IMLoginManager.get(mContext).getUserInfo().getId() + "&token=" + IMLoginManager.get(mContext).getUserInfo().getToken();