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..0c457eab4 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; @@ -392,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; } } @@ -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/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/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..733b3d72f 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" /> + + + + + + + + + + + + + -