From 43c22fca7c2dec5f9aa0821a2df1c10551e55bad Mon Sep 17 00:00:00 2001 From: 18142669586 <1669783059@qq.com> Date: Thu, 29 Dec 2022 15:17:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=BB=E6=92=ADPK=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/event/AnchorInfoEvent.java | 47 +++++++++++++ .../presenter/LiveRyLinkMicPkPresenter.java | 8 +++ .../live/views/LivePushRyViewHolder.java | 30 ++++++++ .../src/main/res/layout/view_live_push_ry.xml | 70 +++++++++++++++---- live/src/main/res/layout/view_live_room.xml | 1 - 5 files changed, 140 insertions(+), 16 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/event/AnchorInfoEvent.java diff --git a/common/src/main/java/com/yunbao/common/event/AnchorInfoEvent.java b/common/src/main/java/com/yunbao/common/event/AnchorInfoEvent.java new file mode 100644 index 000000000..e15712cc0 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/AnchorInfoEvent.java @@ -0,0 +1,47 @@ +package com.yunbao.common.event; + +public class AnchorInfoEvent { + protected boolean clear; + protected String id; + protected String userNiceName; + protected String avatar; + + public AnchorInfoEvent(boolean clears,String ids, String userNiceNames,String avatars) { + clear = clears; + id = ids; + userNiceName = userNiceNames; + avatar = avatars; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUserNiceName() { + return userNiceName; + } + + public void setUserNiceName(String userNiceName) { + this.userNiceName = userNiceName; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public boolean isClear() { + return clear; + } + + public void setClear(boolean clear) { + this.clear = clear; + } +} diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index 4afb31a72..e5993db45 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -38,6 +38,8 @@ import com.alibaba.fastjson.JSONObject; import com.tencent.trtc.TRTCCloud; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.bean.UserBean; +import com.yunbao.common.event.AnchorInfoEvent; +import com.yunbao.common.event.FollowEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.live.LiveNetManager; @@ -608,6 +610,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { * 主播与主播PK PK主播发过来的已经接受 */ public void onLinkMicToPk(UserBean u) { + EventBus.getDefault().post(new AnchorInfoEvent(false,u.getId(), u.getUserNiceName(),u.getAvatar())); Log.e("eve", u.getId() + ""); /** * 加入副房间 @@ -770,6 +773,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { msg1.put("pkuid", CommonAppConfig.getInstance().getUid()); msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatarThumb()); msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + EventBus.getDefault().post(new AnchorInfoEvent(false,bean.getId(), bean.getUserNiceName(),bean.getAvatar())); + if (bean != null && bean.isRandomPk()) { msg1.put("random_pk", bean.isRandomPk() ? 1 : 0); msg1.put("is_ladders", bean.getRankPkImgUrl()); @@ -1057,6 +1062,9 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { * 退出多人PK */ public static void leaveDRRoom() { + //清理PK上面对方的头像 + EventBus.getDefault().post(new AnchorInfoEvent(true,"", "","")); + Log.e("ry", "退出多人OKKK" + inputStreamList.size()); isDRPK = 0; for (int i = 0; i < inputStreamList.size(); i++) { 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 b18d24825..a3c663c54 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -25,6 +25,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.alibaba.fastjson.JSONObject; +import com.makeramen.roundedimageview.RoundedImageView; import com.tencent.liteav.device.TXDeviceManager; import com.tencent.rtmp.ITXLivePushListener; import com.tencent.rtmp.TXLiveConstants; @@ -33,6 +34,9 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.UserBean; +import com.yunbao.common.event.AnchorInfoEvent; +import com.yunbao.common.event.FollowEvent; +import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.live.LiveNetManager; @@ -53,6 +57,8 @@ import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter; import com.yunbao.live.socket.SocketSendBean; import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; @@ -100,10 +106,30 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX public static RCRTCLiveInfo rcrtcLiveInfo; private ViewGroup liveActivityContainer; + private TextView tv_avatarOther_name; + private ImageView avatarOther; + private LinearLayout goto_room_view; + + //修改上面主播的头像 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onUPAnchorInfo(AnchorInfoEvent e) { + if (e != null) { + if(e.isClear()==false) { + tv_avatarOther_name.setText(e.getUserNiceName()); + ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther); + goto_room_view.setVisibility(View.VISIBLE); + }else{ + goto_room_view.setVisibility(View.GONE); + + } + } + } + public LivePushRyViewHolder(Context context, ViewGroup parentView) { super(context, parentView); this.contexts = context; + EventBus.getDefault().register(this); } @Override @@ -379,6 +405,10 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view); dr_pk_view.setVisibility(View.GONE); btn_close = (TextView) findViewById(R.id.btn_close); + tv_avatarOther_name = (TextView) findViewById(R.id.tv_avatarOther_name); + avatarOther = (ImageView) findViewById(R.id.avatarOther); + goto_room_view = (LinearLayout) findViewById(R.id.goto_room_view); + goto_room_view.setVisibility(View.GONE); mMainHandler = new Handler(Looper.getMainLooper()); btn_close.setOnClickListener(new View.OnClickListener() { @Override diff --git a/live/src/main/res/layout/view_live_push_ry.xml b/live/src/main/res/layout/view_live_push_ry.xml index dd8c03d43..877d2519c 100644 --- a/live/src/main/res/layout/view_live_push_ry.xml +++ b/live/src/main/res/layout/view_live_push_ry.xml @@ -104,6 +104,46 @@ android:layout_height="match_parent" /> + + + + + + + + + + + + + - From 2e986db686d812d8e0238aef59bd7066591b201c Mon Sep 17 00:00:00 2001 From: 18142669586 <1669783059@qq.com> Date: Thu, 29 Dec 2022 16:12:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=96=AE=E4=BA=BAPK=E5=8D=A10=E5=88=86=20?= =?UTF-8?q?=E5=84=AA=E5=8C=96=E8=A8=88=E7=AE=97=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/presenter/LiveRyLinkMicPkPresenter.java | 8 ++++---- .../com/yunbao/live/views/LiveLinkMicPkViewHolder.java | 8 ++++++-- live/src/main/res/layout/view_live_push_ry.xml | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index e5993db45..0c457eab4 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -394,10 +394,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { ((LiveRyAnchorActivity) mContext).setPkBtnVisible(true); } //如果PK结束Im没有发送关闭PK的消息,倒计时结束自动关闭 - if (mLiveLinkMicPkViewHolder != null) { - mLiveLinkMicPkViewHolder.removeFromParent(); - mLiveLinkMicPkViewHolder.release(); - } +// if (mLiveLinkMicPkViewHolder != null) { +// mLiveLinkMicPkViewHolder.removeFromParent(); +// mLiveLinkMicPkViewHolder.release(); +// } mLiveLinkMicPkViewHolder = null; } } 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 616b14366..c83022461 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java @@ -190,8 +190,12 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder { public void setTime(String content) { if (mTime != null) { - - mTime.setText(content); + Log.i("vvvs",content); + if(content.trim().equals("00:01")||content.trim().equals("00:00")){ + mTime.setText("計算中"); + }else { + mTime.setText(content); + } } } diff --git a/live/src/main/res/layout/view_live_push_ry.xml b/live/src/main/res/layout/view_live_push_ry.xml index 877d2519c..733b3d72f 100644 --- a/live/src/main/res/layout/view_live_push_ry.xml +++ b/live/src/main/res/layout/view_live_push_ry.xml @@ -110,7 +110,7 @@ android:layout_width="wrap_content" android:layout_height="27dp" android:layout_alignParentRight="true" - android:layout_marginTop="120dp" + android:layout_marginTop="122dp" android:layout_marginRight="9dp" android:background="@drawable/bg_live_other_ico" android:gravity="center"> @@ -174,7 +174,7 @@ android:paddingBottom="5dp" android:paddingLeft="8dp" android:paddingRight="8dp" - android:layout_marginTop="420dp" + android:layout_marginTop="400dp" android:layout_marginRight="8dp" android:layout_alignParentRight="true" android:text="結束連麥"