修改侧边栏跳转问题

This commit is contained in:
18401019693 2023-04-14 16:09:02 +08:00
parent 90c7483dbc
commit 32e3584fef
4 changed files with 33 additions and 14 deletions

View File

@ -461,7 +461,7 @@ public class JavascriptInterfaceUtils {
} else {
url1 = svg;
}
GiftCacheUtil.getFile(mContext,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
GiftCacheUtil.getFile(mContext, Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {
@ -493,20 +493,21 @@ public class JavascriptInterfaceUtils {
/**
* 设置webView高度
*
* @param useDp 是否用dp换算
*/
@JavascriptInterface
public void setHeight(String height, String width,boolean useDp) {
public void setHeight(String height, String width, boolean useDp) {
if ("0".equals(height)) {
return;
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
ViewGroup.LayoutParams params = mWebView.getLayoutParams();
if("-1".equals(height)){
params.height=ViewGroup.LayoutParams.MATCH_PARENT;
}else {
params.height = useDp?DpUtil.dp2px(Integer.parseInt(height)):Integer.parseInt(height);
if ("-1".equals(height)) {
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
params.height = useDp ? DpUtil.dp2px(Integer.parseInt(height)) : Integer.parseInt(height);
}
mWebView.setLayoutParams(params);
mWebView.setVisibility(View.VISIBLE);
@ -515,22 +516,30 @@ public class JavascriptInterfaceUtils {
/**
* 社区分享
*
* @param avatar 头像
* @param link 分享连接
* @param link 分享连接
*/
@JavascriptInterface
public void androidCommunityShare(String avatar,String link){
JSONObject json=new JSONObject();
json.put("avatar",avatar);
json.put("link",link);
public void androidCommunityShare(String avatar, String link) {
JSONObject json = new JSONObject();
json.put("avatar", avatar);
json.put("link", link);
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidCommunityShare")
.setData(json.toJSONString()));
}
@JavascriptInterface
public void androidInviteShare(String url){
public void androidInviteShare(String url) {
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidInviteShare")
.setData(url));
}
@JavascriptInterface
public void closeLiveRoom() {
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("closeLiveRoom"));
}
}

View File

@ -58,6 +58,7 @@ import com.yunbao.common.dialog.SlideSettingsDialog;
import com.yunbao.common.dialog.YoursystemisolderDialog;
import com.yunbao.common.event.CustomDrawerPopupEvent;
import com.yunbao.common.event.FollowEvent;
import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
@ -752,6 +753,15 @@ public class LiveAudienceActivity extends LiveActivity {
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
if (!TextUtils.isEmpty(event.getMethod())) {
if (TextUtils.equals(event.getMethod(), "closeLiveRoom")) {
onBackPressed();
}
}
}
/**
* 跳转页面或者弹窗展示
*

View File

@ -338,7 +338,8 @@ public class LiveAudienceEvent extends BaseModel {
LIVE_PK_ING(59, "PK中"),
LIVE_PK_END(60, "PK结束"),
XYD_COMPLETE(62, "心愿单完成"),
WISH_LIST_PROGRESS(61, "心愿单进度");
WISH_LIST_PROGRESS(61, "心愿单进度"),
CLOSE_LIVE_ROOM(62, "关闭直播间");
private int type;
private String name;

View File

@ -1939,7 +1939,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
flipper.startFlipping();
flipper.setOnClickListener(view -> {
ToastUtil.show(String.valueOf(flipper.getDisplayedChild()));
Bundle bundle = new Bundle();
String path = model.getHourchartH5Url();
if (!path.startsWith("/")) {