From 752fae680cd477e79ec235a8a5a37875ec0503a1 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 10 Nov 2022 16:41:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=A3=E5=91=B3=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/CustomDrawerPopupAdapter.java | 18 +- .../common/bean/CustomSidebarChildModel.java | 11 ++ .../common/bean/CustomSidebarInfoModel.java | 4 + .../common/event/CustomDrawerPopupEvent.java | 34 ++++ .../common/views/CustomDrawerPopupView.java | 17 +- .../common/views/FunGamesChildViewHolder.java | 5 + .../common/views/FunGamesViewHolder.java | 34 ++++ .../live/activity/LiveAudienceActivity.java | 173 +++++++++++------- 8 files changed, 231 insertions(+), 65 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java index 34920b913..b36bd2544 100644 --- a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java @@ -2,6 +2,7 @@ package com.yunbao.common.adapter; import android.app.Activity; import android.content.Context; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -34,6 +35,7 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { private final int FUN_GAMES = 3; private final int RIGHTS_INTERESTS = 4; private final int RECOMMEND = 5; + private String liveId; private List list = new ArrayList<>(); private List infoModels = new ArrayList<>(); @@ -42,6 +44,12 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { this.mContext = mContext; } + + public CustomDrawerPopupAdapter setLiveId(String liveId) { + this.liveId = liveId; + return this; + } + public CustomDrawerPopupAdapter setList(List list) { this.list = list; return this; @@ -98,7 +106,15 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { public void onSuccess(AnchorRecommendModel anchorRecommendModel) { List models = anchorRecommendModel.getList(); - + int userIndex = -1; + for (int i = 0; i < models.size(); i++) { + if (TextUtils.equals(models.get(i).getUid(), liveId)) { + userIndex = i; + } + } + if (userIndex != -1) { + models.remove(userIndex); + } recommendViewHolder.updateData(models); } diff --git a/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java b/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java index ff382aedd..cd1d238ea 100644 --- a/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java +++ b/common/src/main/java/com/yunbao/common/bean/CustomSidebarChildModel.java @@ -28,6 +28,17 @@ public class CustomSidebarChildModel extends BaseModel { private String needNum; @SerializedName("now_num") private String nowNum; + @SerializedName("activity_id") + private String activityId; + + public String getActivityId() { + return activityId; + } + + public CustomSidebarChildModel setActivityId(String activityId) { + this.activityId = activityId; + return this; + } private int resIcon; diff --git a/common/src/main/java/com/yunbao/common/bean/CustomSidebarInfoModel.java b/common/src/main/java/com/yunbao/common/bean/CustomSidebarInfoModel.java index 9d3c85547..5e3ab5547 100644 --- a/common/src/main/java/com/yunbao/common/bean/CustomSidebarInfoModel.java +++ b/common/src/main/java/com/yunbao/common/bean/CustomSidebarInfoModel.java @@ -10,14 +10,18 @@ import java.util.List; public class CustomSidebarInfoModel extends BaseModel { @SerializedName("id") private String id; + //一级标题 @SerializedName("title") private String title; + //二级标题 @SerializedName("subtitle") private String subtitle; @SerializedName("sort") private String sort; + //1全屏 2半屏 @SerializedName("show_type") private String showType; + //跳转链接 @SerializedName("src") private String src; @SerializedName("type") diff --git a/common/src/main/java/com/yunbao/common/event/CustomDrawerPopupEvent.java b/common/src/main/java/com/yunbao/common/event/CustomDrawerPopupEvent.java index 27727b151..0a113460b 100644 --- a/common/src/main/java/com/yunbao/common/event/CustomDrawerPopupEvent.java +++ b/common/src/main/java/com/yunbao/common/event/CustomDrawerPopupEvent.java @@ -5,7 +5,41 @@ import com.yunbao.common.bean.BaseModel; public class CustomDrawerPopupEvent extends BaseModel { //是否关闭弹窗 private boolean isDisMiss = false; + //权益的名字 private String rightsInterests = ""; + //活动的id + private int activityId = -1; + //跳转网页地址 + private String htmlUrl; + //是否半屏展示 + private boolean screen = false; + + public String getHtmlUrl() { + return htmlUrl; + } + + public CustomDrawerPopupEvent setHtmlUrl(String htmlUrl) { + this.htmlUrl = htmlUrl; + return this; + } + + public boolean isScreen() { + return screen; + } + + public CustomDrawerPopupEvent setScreen(boolean screen) { + this.screen = screen; + return this; + } + + public int getActivityId() { + return activityId; + } + + public CustomDrawerPopupEvent setActivityId(int activityId) { + this.activityId = activityId; + return this; + } public String getRightsInterests() { return rightsInterests; diff --git a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java index 393b61a04..bb1d81dab 100644 --- a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java +++ b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java @@ -1,6 +1,7 @@ package com.yunbao.common.views; import android.content.Context; +import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.recyclerview.widget.LinearLayoutManager; @@ -28,6 +29,12 @@ public class CustomDrawerPopupView extends DrawerPopupView { private RecyclerView drawerList; private CustomDrawerPopupAdapter adapter; private List list = new ArrayList<>(); + private String liveId; + + public CustomDrawerPopupView setLiveId(String liveId) { + this.liveId = liveId; + return this; + } public CustomDrawerPopupView setList(List list) { this.list = list; @@ -62,7 +69,7 @@ public class CustomDrawerPopupView extends DrawerPopupView { private void initView() { drawerList = findViewById(R.id.drawerList); adapter = new CustomDrawerPopupAdapter(mContext); - adapter.setList(list); + adapter.setList(list).setLiveId(liveId); drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); drawerList.setAdapter(adapter); adapter.setListener(new CustomDrawerPopupAdapter.CustomDrawerListener() { @@ -101,12 +108,20 @@ public class CustomDrawerPopupView extends DrawerPopupView { void goToLive(AnchorRecommendItemModel model); void informationTransfer(CustomDrawerPopupEvent event); + + void funGamesID(int zfunGamesID); + + void showerHtml(String htmlUrl, boolean screen); } @Subscribe(threadMode = ThreadMode.MAIN) public void OnCustomDrawerPopupEvent(CustomDrawerPopupEvent event) { if (callBack != null) { callBack.informationTransfer(event); + callBack.funGamesID(event.getActivityId()); + if (!TextUtils.isEmpty(event.getHtmlUrl())) { + callBack.showerHtml(event.getHtmlUrl(), event.isScreen()); + } } //是否关闭弹窗 if (event.isDisMiss()) { diff --git a/common/src/main/java/com/yunbao/common/views/FunGamesChildViewHolder.java b/common/src/main/java/com/yunbao/common/views/FunGamesChildViewHolder.java index 7b55f82b9..369949448 100644 --- a/common/src/main/java/com/yunbao/common/views/FunGamesChildViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/FunGamesChildViewHolder.java @@ -1,5 +1,6 @@ package com.yunbao.common.views; +import android.text.TextUtils; import android.view.View; import android.widget.ImageView; import android.widget.TextView; @@ -41,6 +42,10 @@ public class FunGamesChildViewHolder extends RecyclerView.ViewHolder { if (!rigts) { Bus.get().post(new CustomDrawerPopupEvent() .setDisMiss(true).setRightsInterests(model.getTitle())); + } else { + int activityID = TextUtils.isEmpty(model.getActivityId()) ? -1 : Integer.parseInt(model.getActivityId()); + Bus.get().post(new CustomDrawerPopupEvent() + .setDisMiss(true).setActivityId(activityID)); } } }); diff --git a/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java index 4a7494997..1d644ef21 100644 --- a/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java @@ -1,5 +1,7 @@ package com.yunbao.common.views; +import android.os.Bundle; +import android.text.TextUtils; import android.view.View; import android.widget.TextView; @@ -7,9 +9,16 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.yunbao.common.CommonAppConfig; import com.yunbao.common.R; import com.yunbao.common.adapter.FunGamesAdapter; import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.event.CustomDrawerPopupEvent; +import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; public class FunGamesViewHolder extends RecyclerView.ViewHolder { private FunGamesAdapter funGamesAdapter; @@ -24,11 +33,36 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder { funGamesAdapter = new FunGamesAdapter(itemView.getContext(), true); childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 4)); childList.setAdapter(funGamesAdapter); + } public void setData(CustomSidebarInfoModel model) { sendGoodGift.setText(model.getTitle()); subtitle.setText(model.getSubtitle()); funGamesAdapter.updateData(model.getChild()); + ViewClicksAntiShake.clicksAntiShake(subtitle, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (TextUtils.isEmpty(model.getSrc())) { + ToastUtil.show("SHOWER_ERROR"); + } else { + IMLoginModel userInfo = IMLoginManager.get(itemView.getContext()).getUserInfo(); + StringBuffer htmlUrl = new StringBuffer(); + htmlUrl.append(CommonAppConfig.HOST) + .append("/") + .append(model.getSrc()) + .append("&uid=") + .append(userInfo.getId()) + .append("&token=") + .append(userInfo.getToken()); + Bus.get().post(new CustomDrawerPopupEvent() + .setDisMiss(true) + .setHtmlUrl(htmlUrl.toString()) + .setScreen(TextUtils.equals(model.getShowType(), "2"))); + } + + + } + }); } } 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 68b4d1b98..1b089a1e3 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -85,6 +85,7 @@ import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveGiftDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; +import com.yunbao.live.dialog.LiveTotalDialog; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.dialog.SignDialogFragment; import com.yunbao.live.event.LinkMicTxAccEvent; @@ -692,91 +693,138 @@ public class LiveAudienceActivity extends LiveActivity { Bundle bundle = new Bundle(); Log.i("SocketRyClient", "onOpenDrawer: " + event.getType() + " " + event); IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); - CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext).setList(list); - customDrawerPopupView.setCallBack(new CustomDrawerPopupView.CustomDrawerPopupCallBack() { - @Override - public void goToLive(AnchorRecommendItemModel model) { - //获取直播间状态 - LiveHttpUtil.getLiveInfo(model.getUid(), liveInfo); - customDrawerPopupView.dismiss(); - } - @Override - public void informationTransfer(CustomDrawerPopupEvent event) { - //跳转贵族 - if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.noble))) { - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.NOBLE)); - //跳转守护 - } else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.guard_guard))) { - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.GUARD)); - //跳转粉丝团 - } else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.fan_club))) { - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB)); - } - } - }); switch (event.getType()) { case SIDEBAR: case BOTTOM_COLLECTION: - new XPopup.Builder(mContext) - .hasShadowBg(false) - .isDestroyOnDismiss(true) - .isLightStatusBar(false) - .popupPosition(PopupPosition.Right)//右边 - .hasStatusBarShadow(true) //启用状态栏阴影 - .setPopupCallback(new XPopupCallback() { - @Override - public void onCreated(BasePopupView popupView) { + if (event.isActivity()) { + LiveTotalDialog liveTotalDialog = new LiveTotalDialog(); + liveTotalDialog.setAnchorBean(mLiveBean); + Bundle liveBundle = new Bundle(); + liveBundle.putBoolean("isActivity", event.isActivity()); + liveTotalDialog.setArguments(liveBundle); + liveTotalDialog.show(getSupportFragmentManager(), "LiveTotalDialog"); + } else { + int userIndex = -1; + for (int i = 0; i < list.size(); i++) { + if (TextUtils.equals(list.get(i).getUid(), PortraitLiveManager.liveID)) { + userIndex = i; + } + } + if (userIndex != -1) { + list.remove(userIndex); + } + CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext).setList(list).setLiveId(mLiveBean.getUid()); + customDrawerPopupView.setCallBack(new CustomDrawerPopupView.CustomDrawerPopupCallBack() { + @Override + public void funGamesID(int zfunGamesID) { + if (zfunGamesID != 0) { + LiveGameDialogFragment fragment = new LiveGameDialogFragment(); + fragment.setActivityId(zfunGamesID); + fragment.setRoomId(mLiveUid); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment"); + } else { } + } - @Override - public void beforeShow(BasePopupView popupView) { + @Override + public void goToLive(AnchorRecommendItemModel model) { + //获取直播间状态 + LiveHttpUtil.getLiveInfo(model.getUid(), liveInfo); + customDrawerPopupView.dismiss(); + } + @Override + public void informationTransfer(CustomDrawerPopupEvent event) { + //跳转贵族 + if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.noble))) { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.NOBLE)); + //跳转守护 + } else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.guard_guard))) { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.GUARD)); + //跳转粉丝团 + } else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.fan_club))) { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB)); } + } - @Override - public void onShow(BasePopupView popupView) { - + @Override + public void showerHtml(String htmlUrl, boolean screen) { + if (!screen) { + ZhuangBanActivity.forward(mContext, htmlUrl, false); + } else { + Bundle bundle = new Bundle(); + bundle.putString("url", htmlUrl); + LiveHDDialogFragment fragment = new LiveHDDialogFragment(); + fragment.setArguments(bundle); + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); } + } + }); + new XPopup.Builder(mContext) + .hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Right)//右边 + .hasStatusBarShadow(true) //启用状态栏阴影 + .setPopupCallback(new XPopupCallback() { + @Override + public void onCreated(BasePopupView popupView) { - @Override - public void onDismiss(BasePopupView popupView) { - getDrawer(); - } + } - @Override - public void beforeDismiss(BasePopupView popupView) { + @Override + public void beforeShow(BasePopupView popupView) { - } + } - @Override - public boolean onBackPressed(BasePopupView popupView) { - return false; - } + @Override + public void onShow(BasePopupView popupView) { - @Override - public void onKeyBoardStateChanged(BasePopupView popupView, int height) { + } - } + @Override + public void onDismiss(BasePopupView popupView) { + getDrawer(); + } - @Override - public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) { + @Override + public void beforeDismiss(BasePopupView popupView) { - } + } - @Override - public void onClickOutside(BasePopupView popupView) { + @Override + public boolean onBackPressed(BasePopupView popupView) { + return false; + } + + @Override + public void onKeyBoardStateChanged(BasePopupView popupView, int height) { + + } + + @Override + public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) { + + } + + @Override + public void onClickOutside(BasePopupView popupView) { + + } + }) + .asCustom(customDrawerPopupView) + .show(); + } - } - }) - .asCustom(customDrawerPopupView) - .show(); break; + case GIFT_POPUP: + if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) { return; } @@ -1102,7 +1150,6 @@ public class LiveAudienceActivity extends LiveActivity { slideInfoModels.clear(); List models = anchorRecommendModel.getList(); - models.add(0, new AnchorRecommendItemModel()); list.addAll(models); slideInfoModels = anchorRecommendModel.getSlide(); }