From 3d608145385af6a0291845bd5e262f18c06b54ac Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 14 Dec 2022 11:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E4=BA=BAPK=E5=9D=90?= =?UTF-8?q?=E5=B8=AD=E5=A4=B4=E5=83=8F=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/event/CoinChangeEvent.java | 13 --- .../yunbao/live/activity/LiveActivity.java | 91 ++++++++++++------- .../yunbao/live/event/LiveAudienceEvent.java | 11 +++ .../live/views/LiveLinkMicPkViewHolder.java | 2 +- .../live/views/LivePushRyViewHolder.java | 4 + .../yunbao/live/views/LiveRoomViewHolder.java | 54 ++++++----- .../live/views/PortraitLiveManager.java | 46 ++++++---- 7 files changed, 133 insertions(+), 88 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/event/CoinChangeEvent.java b/common/src/main/java/com/yunbao/common/event/CoinChangeEvent.java index 972546e24..56130e8b3 100644 --- a/common/src/main/java/com/yunbao/common/event/CoinChangeEvent.java +++ b/common/src/main/java/com/yunbao/common/event/CoinChangeEvent.java @@ -10,20 +10,7 @@ public class CoinChangeEvent { private String coin; private String goldCoinNum; private boolean chargeSuccess; - //重置头像 - private boolean resetProfilePicture = false; - public boolean isResetProfilePicture() { - return resetProfilePicture; - } - - public CoinChangeEvent() { - } - - public CoinChangeEvent setResetProfilePicture(boolean resetProfilePicture) { - this.resetProfilePicture = resetProfilePicture; - return this; - } public CoinChangeEvent(String coin) { this.coin = coin; diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index 7821ec567..9ec322ca1 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -161,6 +161,18 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL mPageContainer = findViewById(R.id.page_container); EventBus.getDefault().register(this); mDialogFragmentSet = new HashSet<>(); + //解压 美颜模型 + /*try { + CommonAppConfig.VIDEO_TIE_MODEl_PATH = getFilesDir().getAbsolutePath() + "/model";//app安装路径 + File model = new File(CommonAppConfig.VIDEO_TIE_MODEl_PATH); + if (model.exists() && Objects.requireNonNull(model.listFiles()).length > 0) { + return; + } + UnzipFromAssets.unZip(LiveActivity.this, "model-all.zip", CommonAppConfig.VIDEO_TIE_MODEl_PATH, false); + } catch (Exception e) { + e.printStackTrace(); + Log.i("log", "beauty e=" + e); + }*/ } @Override @@ -211,9 +223,17 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL if (!mFirstConnectSocket) { mFirstConnectSocket = true; if (mLiveType == Constants.LIVE_TYPE_PAY || mLiveType == Constants.LIVE_TYPE_TIME) { +// if (isRy == false) { +// SocketChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1); +// } else { SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1); +// } } +// if (isRy == false) { +// SocketChatUtil.getFakeFans(mLiveUid); +// } else { SocketRyChatUtil.getFakeFans(mLiveUid); +// } } } } @@ -614,13 +634,23 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onLinkMicAnchorClose() { - +// if (isRy == false) { +// if (mLiveLinkMicAnchorPresenter != null) { +// mLiveLinkMicAnchorPresenter.onLinkMicAnchorClose(); +// } +// if (mLiveLinkMicPkPresenter != null) { +// mLiveLinkMicPkPresenter.onLinkMicPkClose(1); +// } +// } else { if (mLiveLinkMicAnchorPresenter != null) { mLiveLinkMicAnchorPresenter.onLinkMicAnchorClose(); } if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkClose(1); } +// } + + if (this instanceof LiveAudienceActivity) { ((LiveAudienceActivity) this).onLinkMicTxAnchor(false); } @@ -674,33 +704,26 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL /** * 主播与主播PK 所有人收到PK开始的回调 */ - private String mPkUid, mPkhead, mPkname, mIsLadders; - private Handler linkMicPkStartHandler = new Handler(); - - private Runnable linkMicPkStartRunnable = new Runnable() { - - @Override - public void run() { - if (mLiveRoomViewHolder != null) { - Log.e("tasdsdg", mLiveUid + "1111" + CommonAppConfig.getInstance().getUid()); - if (!mLiveUid.equals(CommonAppConfig.getInstance().getUid())) { - mLiveRoomViewHolder.setOtherInfo(mPkUid, mPkhead, mPkname); - mLiveRoomViewHolder.initPkRank(mIsLadders); - } - } - } - }; - @Override public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname, String isLadders) { + if (mContext instanceof LiveAudienceActivity) return; Log.e("ry", "pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders); - mPkUid = pkUid; - mPkhead = pkhead; - mPkname = pkname; - mIsLadders = isLadders; if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); - linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法 + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + if (mLiveRoomViewHolder != null) { + Log.e("tasdsdg", mLiveUid + "1111" + CommonAppConfig.getInstance().getUid()); + if (!mLiveUid.equals(CommonAppConfig.getInstance().getUid())) { + mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); + mLiveRoomViewHolder.initPkRank(isLadders); + } + } + } + }, 4000);//3秒后执行Runnable中的run方法 + } } @@ -823,6 +846,13 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 打开聊天输入框 */ public void openChatWindow() { +// if (mKeyBoardHeightUtil == null) { +// mKeyBoardHeightUtil = new KeyBoardHeightUtil2(mContext, super.findViewById(android.R.id.content), this); +// mKeyBoardHeightUtil.start(); +// } +// if (mLiveRoomViewHolder != null) { +// mLiveRoomViewHolder.chatScrollToBottom(); +// } LiveInputDialogFragment fragment = new LiveInputDialogFragment(); Bundle bundle = new Bundle(); bundle.putString(Constants.LIVE_DANMU_PRICE, mDanmuPrice); @@ -1147,19 +1177,10 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Subscribe(threadMode = ThreadMode.MAIN) public void onCoinChangeEvent(CoinChangeEvent e) { - if (e.isResetProfilePicture()) { - mPkUid = null; - mPkhead = null; - mPkname = null; - mIsLadders = null; - linkMicPkStartHandler.removeCallbacks(linkMicPkStartRunnable); - } else { - onCoinChanged(e.getCoin()); - if (e.isChargeSuccess() && this instanceof LiveAudienceActivity) { - ((LiveAudienceActivity) this).onChargeSuccess(); - } + onCoinChanged(e.getCoin()); + if (e.isChargeSuccess() && this instanceof LiveAudienceActivity) { + ((LiveAudienceActivity) this).onChargeSuccess(); } - } public void onCoinChanged(String coin) { 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 af4ba5b01..a1ea3913f 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -8,6 +8,7 @@ import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.MsgModel; import com.yunbao.common.event.CustomFullServiceNotifyEvent; +import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.bean.OpenParametersModel; public class LiveAudienceEvent extends BaseModel { @@ -29,6 +30,16 @@ public class LiveAudienceEvent extends BaseModel { private String uid; private int time; private CustomFullServiceNotifyEvent customFullServiceNotifyEvent; + private LivePKUserListBean livePKUserListBean; + + public LivePKUserListBean getLivePKUserListBean() { + return livePKUserListBean; + } + + public LiveAudienceEvent setLivePKUserListBean(LivePKUserListBean livePKUserListBean) { + this.livePKUserListBean = livePKUserListBean; + return this; + } public CustomFullServiceNotifyEvent getCustomFullServiceNotifyEvent() { return customFullServiceNotifyEvent; diff --git a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java index 74f922ae3..ca91e2de5 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java @@ -236,7 +236,7 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder { animationDrawable.start(); } - EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_UPDATE_HEAD_DATA).setObject(bean)); + EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_UPDATE_HEAD_DATA).setLivePKUserListBean(bean)); } private void changeLine(float nowIndex, long leftGift, long rightGift) { diff --git a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java index ece604961..2fbe77345 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -45,12 +45,15 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.momo.TencentTRTCBeautyManager; import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter; import com.yunbao.live.socket.SocketSendBean; +import org.greenrobot.eventbus.EventBus; + import java.util.ArrayList; import java.util.List; @@ -327,6 +330,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX } mLiveRyLinkMicPkPresenter.onLinkMicToPk(userBean1); mLiveRyLinkMicPkPresenter.onLinkMicPkStart(inviteeRoomId, 3); + EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UP_PK_TWO)); } } }); 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 276b1a5a4..0d574cb84 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1103,7 +1103,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * 重置该隐藏的view */ public void resetViewGone() { - EventBus.getDefault().post(new CoinChangeEvent().setResetProfilePicture(true)); goto_room_view.setVisibility(View.GONE); mPkRankTopIcon.setVisibility(View.GONE); lt_pk_line.setVisibility(View.GONE); @@ -1887,23 +1886,31 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis //头像显示 public void setHeadData(LivePKUserListBean bean) { + if (bean == null) return; + Log.e("更新礼物进度", bean.toString()); livePKUserListBean = bean; String mLiveuid = LiveRoomViewHolder.mLiveUid; if (livePKUserListBean != null) { - if (!lt_pk_line.isShown()) { - UpPkTwo(); + if (lt_pk_line.getVisibility() == View.GONE) { + ScreenDimenUtil util = ScreenDimenUtil.getInstance(); + int mScreenWdith = util.getScreenWdith(); + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams(); + params.height = mScreenWdith * 720 / 1120; + lt_pk_line.requestLayout(); + + lt_pk_line.setVisibility(View.VISIBLE); } Boolean idB = true; if (livePKUserListBean.getRed_one() != null && livePKUserListBean.getBlue_one() != null) { if (mLiveuid.equals(livePKUserListBean.getRed_one().getLiveuid())) { - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getRed_one().getImg(), avatar_l1); - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getBlue_one().getImg(), avatar_r1); + ImgLoader.display2(mContext, livePKUserListBean.getRed_one().getImg(), avatar_l1); + ImgLoader.display2(mContext, livePKUserListBean.getBlue_one().getImg(), avatar_r1); uidL1 = livePKUserListBean.getRed_one().getUid(); uidR1 = livePKUserListBean.getBlue_one().getUid(); idB = true; } else { - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getRed_one().getImg(), avatar_r1); - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getBlue_one().getImg(), avatar_l1); + ImgLoader.display2(mContext, livePKUserListBean.getRed_one().getImg(), avatar_r1); + ImgLoader.display2(mContext, livePKUserListBean.getBlue_one().getImg(), avatar_l1); uidR1 = livePKUserListBean.getRed_one().getUid(); uidL1 = livePKUserListBean.getBlue_one().getUid(); idB = false; @@ -1911,35 +1918,38 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } if (livePKUserListBean.getRed_two() != null && livePKUserListBean.getBlue_two() != null) { if (idB) { - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getRed_two().getImg(), avatar_l2); - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getBlue_two().getImg(), avatar_r2); + ImgLoader.display2(mContext, livePKUserListBean.getRed_two().getImg(), avatar_l2); + ImgLoader.display2(mContext, livePKUserListBean.getBlue_two().getImg(), avatar_r2); uidL2 = livePKUserListBean.getRed_two().getUid(); uidR2 = livePKUserListBean.getBlue_two().getUid(); } else { - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getRed_two().getImg(), avatar_r2); - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getBlue_two().getImg(), avatar_l2); + ImgLoader.display2(mContext, livePKUserListBean.getRed_two().getImg(), avatar_r2); + ImgLoader.display2(mContext, livePKUserListBean.getBlue_two().getImg(), avatar_l2); uidR2 = livePKUserListBean.getRed_two().getUid(); uidL2 = livePKUserListBean.getBlue_two().getUid(); } } if (livePKUserListBean.getRed_three() != null && livePKUserListBean.getBlue_three() != null) { if (idB) { - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getRed_three().getImg(), avatar_l3); - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getBlue_three().getImg(), avatar_r3); + ImgLoader.display2(mContext, livePKUserListBean.getRed_three().getImg(), avatar_l3); + ImgLoader.display2(mContext, livePKUserListBean.getBlue_three().getImg(), avatar_r3); uidL3 = livePKUserListBean.getRed_three().getUid(); uidR3 = livePKUserListBean.getBlue_three().getUid(); } else { - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getRed_three().getImg(), avatar_r3); - ImgLoader.display2((LiveActivity) Contexts, livePKUserListBean.getBlue_three().getImg(), avatar_l3); + ImgLoader.display2(mContext, livePKUserListBean.getRed_three().getImg(), avatar_r3); + ImgLoader.display2(mContext, livePKUserListBean.getBlue_three().getImg(), avatar_l3); uidR3 = livePKUserListBean.getRed_three().getUid(); uidL3 = livePKUserListBean.getBlue_three().getUid(); } } + } else { + UpPkTwo(); } } //双人pk显示 public void UpPkTwo() { + if (lt_pk_line.getVisibility() == View.VISIBLE) return; ScreenDimenUtil util = ScreenDimenUtil.getInstance(); int mScreenWdith = util.getScreenWdith(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams(); @@ -1949,12 +1959,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis lt_pk_line.setVisibility(View.VISIBLE); img_pk_fist_l.setBackgroundResource(R.mipmap.icon_red_no1); img_pk_fist_r.setBackgroundResource(R.mipmap.icon_blue_no1); - ImgLoader.display2(mContext, R.mipmap.icon_sofa_red, avatar_l1); - ImgLoader.display2(mContext, R.mipmap.icon_sofa_red, avatar_l2); - ImgLoader.display2((LiveActivity) Contexts, R.mipmap.icon_sofa_red, avatar_l3); - ImgLoader.display2((LiveActivity) Contexts, R.mipmap.icon_sofa_blue, avatar_r1); - ImgLoader.display2((LiveActivity) Contexts, R.mipmap.icon_sofa_blue, avatar_r2); - ImgLoader.display2((LiveActivity) Contexts, R.mipmap.icon_sofa_blue, avatar_r3); + avatar_l1.setImageResource(R.mipmap.icon_sofa_red); + avatar_l2.setImageResource(R.mipmap.icon_sofa_red); + avatar_l3.setImageResource(R.mipmap.icon_sofa_red); + avatar_r1.setImageResource(R.mipmap.icon_sofa_blue); + avatar_r2.setImageResource(R.mipmap.icon_sofa_blue); + avatar_r3.setImageResource(R.mipmap.icon_sofa_blue); uidL1 = ""; uidL2 = ""; @@ -3804,7 +3814,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis updatePkRank((PkRankBean) event.getObject()); break; case PK_TWO_UPDATE_HEAD_DATA: - setHeadData((LivePKUserListBean) event.getObject()); + setHeadData( event.getLivePKUserListBean()); break; case PK_TWO_START: pkUid = event.getObject().toString(); diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 761115286..a46b0cbed 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -40,7 +40,6 @@ import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.custom.MyViewPager; -import com.yunbao.common.event.CustomFullServiceNotifyEvent; import com.yunbao.common.event.FollowEvent; import com.yunbao.common.event.LiveFloatEvent; import com.yunbao.common.glide.ImgLoader; @@ -307,6 +306,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } }); mLiveRoomViewHolder.resetView(); + linkMicPkStartHandler.removeCallbacks(linkMicPkStartRunnable); mLiveRoomViewHolder.setAvatar(data.getAvatar()); mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); mLiveRoomViewHolder.setName(data.getUserNiceName()); @@ -1215,25 +1215,37 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } + + /** + * 主播与主播PK 所有人收到PK开始的回调 + */ + private String mPkUid, mPkhead, mPkname, mIsLadders; + private Handler linkMicPkStartHandler = new Handler(); + + private Runnable linkMicPkStartRunnable = new Runnable() { + + @Override + public void run() { + if (mLiveRoomViewHolder != null) { + Log.e("tasdsdg", liveID + "1111" + CommonAppConfig.getInstance().getUid()); + if (!liveID.equals(CommonAppConfig.getInstance().getUid())) { + mLiveRoomViewHolder.setOtherInfo(mPkUid, mPkhead, mPkname); + mLiveRoomViewHolder.initPkRank(mIsLadders); + } + } + } + }; + @Override - public void onLinkMicPkStart(String pkUid, String pkhead, String pkname, String isLadders) { - System.out.println("PK测试 pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders); + public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname, String isLadders) { + Log.e("ry", "pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders); + mPkUid = pkUid; + mPkhead = pkhead; + mPkname = pkname; + mIsLadders = isLadders; if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); - Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - @Override - public void run() { - if (mLiveRoomViewHolder != null) { - Log.e("tasdsdg", liveID + "1111" + CommonAppConfig.getInstance().getUid()); - if (!liveID.equals(CommonAppConfig.getInstance().getUid())) { - mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); - mLiveRoomViewHolder.initPkRank(isLadders); - } - } - } - }, 4000);//3秒后执行Runnable中的run方法 - + linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法 } if (mLivePlayViewHolder != null) { mLivePlayViewHolder.setLiveBeanLandscape(1);