调整弹窗

This commit is contained in:
zlzw 2024-06-01 13:13:33 +08:00
parent 0396e2d06d
commit 9764b3370e
3 changed files with 36 additions and 3 deletions

View File

@ -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() {

View File

@ -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();

View File

@ -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();