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 930cb2f8a..9101071ae 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -461,7 +461,7 @@ public class JavascriptInterfaceUtils { } else { url1 = svg; } - GiftCacheUtil.getFile(mContext,Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { + GiftCacheUtil.getFile(mContext, Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback() { @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")); + } } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index cadaa3f2c..04f310dbd 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -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(); + } + } + } + /** * 跳转页面或者弹窗展示 * diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index e1ed47740..89d8dbbd3 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -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; diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 81a096d7f..0ce17e7bf 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -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("/")) {