From cccde7a3f8c03b94171547d705e6cadb631a5f95 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 27 Oct 2022 16:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=B0=83=E6=95=B4=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8Banner=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/bean/BannerBean.java | 9 ++++ .../common/bean/LiveRoomActivityBanner.java | 10 ++++ .../live/dialog/LiveGameDialogFragment.java | 49 ++++++++++++++++++- .../yunbao/live/views/LiveRoomViewHolder.java | 48 +++++++++--------- 4 files changed, 89 insertions(+), 27 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/bean/BannerBean.java b/common/src/main/java/com/yunbao/common/bean/BannerBean.java index e09c9cc55..37767407e 100644 --- a/common/src/main/java/com/yunbao/common/bean/BannerBean.java +++ b/common/src/main/java/com/yunbao/common/bean/BannerBean.java @@ -15,6 +15,7 @@ public class BannerBean { private String mIntoUrl; private int type; private String name; + private int activityId=0; private StarChallengeStatusModel model; @@ -90,6 +91,14 @@ public class BannerBean { public void setName(String name) { this.name = name; } + @JSONField(name = "active_id") + public int getActivityId() { + return activityId; + } + @JSONField(name = "active_id") + public void setActivityId(int activityId) { + this.activityId = activityId; + } @Override public String toString() { diff --git a/common/src/main/java/com/yunbao/common/bean/LiveRoomActivityBanner.java b/common/src/main/java/com/yunbao/common/bean/LiveRoomActivityBanner.java index ab5a47cd0..ded82e352 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveRoomActivityBanner.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveRoomActivityBanner.java @@ -16,6 +16,8 @@ public class LiveRoomActivityBanner extends BaseModel{ private int hidden; @SerializedName("show_type") private String type; + @SerializedName("active_id") + private int activeId; public String getName() { return name; @@ -56,4 +58,12 @@ public class LiveRoomActivityBanner extends BaseModel{ public void setType(String type) { this.type = type; } + + public int getActiveId() { + return activeId; + } + + public void setActiveId(int activeId) { + this.activeId = activeId; + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java index 3b9176a55..ba89264fd 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java @@ -66,12 +66,18 @@ public class LiveGameDialogFragment extends AbsDialogFragment { private String roomId; private TabLayout tabLayout; private int tabIndex = 0; + private int activityId = -1; private LinearLayout layout; + private boolean isFullWindow = false; public LiveGameDialogFragment() { } + public LiveGameDialogFragment(boolean isFullWindow) { + this.isFullWindow = isFullWindow; + } + /** * 设置打开第几个tab */ @@ -79,6 +85,10 @@ public class LiveGameDialogFragment extends AbsDialogFragment { this.tabIndex = index; } + public void setActivityId(int activityId) { + this.activityId = activityId; + } + @Override protected int getLayoutId() { return R.layout.dialog_live_game; @@ -100,7 +110,28 @@ public class LiveGameDialogFragment extends AbsDialogFragment { window.setWindowAnimations(R.style.bottomToTopAnim); WindowManager.LayoutParams params = window.getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; - params.height = DpUtil.dp2px(540); + if (isFullWindow) { + Display display = null; + window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + display = requireContext().getDisplay(); + window.getInsetsController().hide(WindowInsets.Type.statusBars()); + window.getInsetsController().hide(WindowInsets.Type.navigationBars()); + } else { + display = window.getWindowManager().getDefaultDisplay(); + window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); + } + window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + window.getDecorView().setBackgroundColor(Color.parseColor("#10000000")); + params.height = WindowManager.LayoutParams.MATCH_PARENT; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + window.getDecorView().setMinimumHeight(display.getMode().getPhysicalHeight()); + window.getDecorView().setMinimumWidth(display.getMode().getPhysicalWidth()); + } + window.getDecorView().setPadding(10, -10, 0, 0); + } else { + params.height = DpUtil.dp2px(540); + } params.gravity = Gravity.BOTTOM; window.setAttributes(params); } @@ -147,6 +178,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment { @Override public void onSuccess(List data) { initTab(data); + activityToPosition(); selectTab(tabIndex); } @@ -184,6 +216,21 @@ public class LiveGameDialogFragment extends AbsDialogFragment { }); } + /** + * 通过活动id来展示页面 + */ + public void activityToPosition() { + int count = tabLayout.getTabCount(); + for (int i = 0; i < count; i++) { + ActiveModel model = (ActiveModel) tabLayout.getTabAt(i).getTag(); + if ((activityId + "").equals(model.getActiveId())) { + tabIndex=i; + return; + } + } + dismiss(); + } + private void selectTab(int position) { TabLayout.Tab tab = tabLayout.getTabAt(position); if (tab != null) { 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 172ad67e3..35a5f4552 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1289,7 +1289,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void onSuccess(List data) { mBannerList4.clear(); for (LiveRoomActivityBanner datum : data) { + if (datum.getHidden() == 1) { + continue; + } BannerBean bean = new BannerBean(); + bean.setActivityId(datum.getActiveId()); bean.setName(datum.getName()); bean.setLink(datum.getLink()); bean.setImageUrl(datum.getImg()); @@ -3000,13 +3004,19 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis BannerBean bean = mBannerList4.get(p); loadingDialog = DialogUitl.loadingDialog(mContext); loadingDialog.show(); - if ("幸运天使".equals(bean.getName())) { + if (bean.getActivityId() == -1) {//-1写死跳活动弹窗 + Bus.get().post(new LiveAudienceEvent() + .setActivity(true) + .setType(LiveAudienceEvent.LiveAudienceType.BOTTOM_COLLECTION)); + if (loadingDialog != null && loadingDialog.isShowing()) { + loadingDialog.dismiss(); + loadingDialog = null; + } + } else if (bean.getActivityId() == 0) { openWebDialog(bean.getLink()); - } else if ("新人特惠".equals(bean.getName())) { - showNewPeopleInfo(); - }else{ - LiveGameDialogFragment fragment=new LiveGameDialogFragment(); - fragment.selectIndex(0); + } else { + LiveGameDialogFragment fragment = new LiveGameDialogFragment("1".equals(bean.getShow_type())); + fragment.setActivityId(bean.getActivityId()); fragment.setRoomId(mLiveUid); fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment"); if (loadingDialog != null && loadingDialog.isShowing()) { @@ -3016,28 +3026,14 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } - public void showNewPeopleInfo() { - API.get().pdLiveApi(mContext) - .getNewPeopleInfo() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(stringResponseModel -> { - NewPeopleInfo peopleInfo = stringResponseModel.getData().getInfo(); - if (peopleInfo.getIsShow()) { - String newPeopleUrl; - if (peopleInfo.getLink().startsWith("http")) { - newPeopleUrl = peopleInfo.getLink() + "?"; - } else { - newPeopleUrl = CommonAppConfig.HOST + "/" + peopleInfo.getLink(); - } - openWebDialog(newPeopleUrl); - } - }, Throwable::printStackTrace).isDisposed(); - } private void openWebDialog(String url) { if (!url.startsWith("http")) { - url = CommonAppConfig.HOST + url; + if (url.startsWith("/")) { + url = CommonAppConfig.HOST + url; + } else { + url = CommonAppConfig.HOST + "/" + url; + } } if (url.contains("?")) { url += "&"; @@ -3045,7 +3041,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis url += "?"; } url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token=" - + CommonAppConfig.getInstance().getToken()+"&anchorUid="+mLiveUid; + + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; Log.i("tag", url); Bundle bundle1 = new Bundle(); bundle1.putString("url", url);