diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index e1ddc7225..4818972de 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -138,7 +138,7 @@ public class AppContext extends CommonAppContext { CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis()); registerError(); registerFirebaseCrash(); - // LogUtils.start(this); + LogUtils.start(this); sInstance = this; L.setDeBug(BuildConfig.DEBUG); AppEventsLogger.activateApp(this); diff --git a/common/src/main/java/com/yunbao/common/bean/PkRankBean.java b/common/src/main/java/com/yunbao/common/bean/PkRankBean.java index 67af66531..16a3e90e8 100644 --- a/common/src/main/java/com/yunbao/common/bean/PkRankBean.java +++ b/common/src/main/java/com/yunbao/common/bean/PkRankBean.java @@ -1,17 +1,24 @@ package com.yunbao.common.bean; import com.google.gson.annotations.SerializedName; +import com.yunbao.common.utils.StringUtil; /** * 直播间PK排位赛 */ -public class PkRankBean extends BaseModel{ +public class PkRankBean extends BaseModel { @SerializedName("anchor_id") public int id; @SerializedName("rank_name") public String name; @SerializedName("rank_img") public String img; + @SerializedName("win_continuity1") + public String redVal; + @SerializedName("win_continuity2") + public String blueVal; + @SerializedName("pktt_img") + public String pkTopImgUrl; public int getId() { return id; @@ -36,4 +43,46 @@ public class PkRankBean extends BaseModel{ public void setImg(String img) { this.img = img; } + + public String getRedVal() { + if (StringUtil.isEmpty(redVal)) { + redVal = "0"; + } + return redVal; + } + + public void setRedVal(String redVal) { + this.redVal = redVal; + } + + public String getBlueVal() { + if (StringUtil.isEmpty(blueVal)) { + blueVal = "0"; + } + return blueVal; + } + + public void setBlueVal(String blueVal) { + this.blueVal = blueVal; + } + + public String getPkTopImgUrl() { + return pkTopImgUrl; + } + + public void setPkTopImgUrl(String pkTopImgUrl) { + this.pkTopImgUrl = pkTopImgUrl; + } + + @Override + public String toString() { + return "PkRankBean{" + + "id=" + id + + ", name='" + name + '\'' + + ", img='" + img + '\'' + + ", redVal='" + redVal + '\'' + + ", blueVal='" + blueVal + '\'' + + ", pkTopImgUrl='" + pkTopImgUrl + '\'' + + '}'; + } } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 96bec2d61..8ebe3d505 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -268,5 +268,5 @@ public interface PDLiveApi { * PK排位赛接口 */ @GET("/api/public/?service=Ranking.getAnchorRankData") - Observable> getPkRanksList(@Query("anchor_id") String anchorId); + Observable> getPkRanksList(@Query("anchor_id") String anchorId,@Query("anchor_id2")String pkUid); } 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 a8fd702d6..e98110c2d 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -120,8 +120,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL protected LiveLinkMicAnchorPresenter mLiveLinkMicAnchorPresenter;//主播与主播连麦逻辑 protected LiveLinkMicPkPresenter mLiveLinkMicPkPresenter;//主播与主播PK逻辑 public static LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;//主播与主播PK逻辑 - public static SocketClient mSocketClient; - public static SocketRyClient mSocketRyClient; + public SocketClient mSocketClient; + public SocketRyClient mSocketRyClient; protected LiveBean mLiveBean; protected int mLiveSDK;//sdk类型 0金山 1腾讯 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 88cd47779..183e6bf26 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -16,6 +16,7 @@ public class LiveAudienceEvent extends BaseModel { private AnchorRecommendItemModel anchorRecommendItemModel = new AnchorRecommendItemModel(); private int micIng = 0;//连麦状态 private LiveBean bean; + private Object object; private int liveType; private int liveTypeVal; private MsgModel msgModel;//全服消息 @@ -140,6 +141,15 @@ public class LiveAudienceEvent extends BaseModel { return this; } + public Object getObject() { + return object; + } + + public LiveAudienceEvent setObject(Object object) { + this.object = object; + return this; + } + public enum LiveAudienceType { SIDEBAR(1, "侧边栏"), BOTTOM_COLLECTION(2, "底部合集"), @@ -175,7 +185,10 @@ public class LiveAudienceEvent extends BaseModel { WE_CHEAT(32, "整蛊"), WISH_LIST_UPDATE(33, "心愿单更新推送"), UN_LEAVELIVE(34, "取消暂时离开"), - PK_RANK_UPDATE(35, "PK排位赛更新") + PK_RANK_UPDATE(35, "PK排位赛更新"), + PK_TWO_START(36, "双人PK开始"), + PK_TWO_UPDATE_HEAD_DATA(37, "更新PK头像信息"), + PK_TWO_END(38, "双人PK开始"), ; private int type; 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 a33315537..5bef0d5ee 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -82,6 +82,8 @@ import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view; import static com.yunbao.live.views.LivePushRyViewHolder.rcrtcLiveInfo; import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom; +import org.greenrobot.eventbus.EventBus; + //import cn.rongcloud.rtc.jni.video.RCRect; /** @@ -1839,6 +1841,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { } mLiveLinkMicPkViewHolder.startAnim(); + EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_START).setObject(pkUid)); mLiveLinkMicPkViewHolder.showTime(); nextPkTimeCountDown(); if (mIsAnchor) { diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index b02dc58d8..3e6643e18 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -523,7 +523,9 @@ public class SocketRyClient { pkRankBean.setId(Integer.parseInt(item.getString("new_rank_id"))); pkRankBean.setName(item.getString("new_rank_name")); pkRankBean.setImg(item.getString("new_rank_img")); - EventBus.getDefault().post(pkRankBean); + EventBus.getDefault().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_UPDATE) + .setObject(pkRankBean)); break; } } 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 98b20a3a5..c1b6fd9c6 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveLinkMicPkViewHolder.java @@ -20,6 +20,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.WordUtil; @@ -29,8 +30,11 @@ import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.custom.FrameImageView; import com.yunbao.live.custom.PkProgressBar; import com.yunbao.live.custom.ProgressTextView; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.utils.LiveIconUtil; +import org.greenrobot.eventbus.EventBus; + import cn.qqtheme.framework.util.ScreenUtils; /** @@ -177,7 +181,6 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder { animationDrawable = (AnimationDrawable) frame_img_pk.getBackground(); animationDrawable.start(); } - LiveRoomViewHolder.UpPkTwo(); } public void showTime() { @@ -239,7 +242,7 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder { animationDrawable.start(); } - LiveRoomViewHolder.setHeadData(bean); + EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_UPDATE_HEAD_DATA).setObject(bean)); } private void changeLine(float nowIndex, long leftGift, long rightGift) { @@ -496,8 +499,8 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder { if (animationDrawable != null) { animationDrawable.stop(); } - - LiveRoomViewHolder.closePkTwo(); + + EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_END)); } public void setIsAnchor(boolean flag) { 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 f9428c15f..d06188889 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -91,6 +91,7 @@ import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.SpUtil; import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.views.AbsViewHolder; @@ -275,8 +276,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public static ImageView img_pk_fist_l, img_pk_fist_r; public static RoundedImageView avatar_l1, avatar_l2, avatar_l3, avatar_r1, avatar_r2, avatar_r3; public static LivePKUserListBean livePKUserListBean; - public static String uidL1, uidL2, uidL3, uidR1, uidR2, uidR3; - public static RelativeLayout lt_pk_line; + public String uidL1, uidL2, uidL3, uidR1, uidR2, uidR3; + public RelativeLayout lt_pk_line; public WindowManager windowManager; // public boolean isRy = false; @@ -312,6 +313,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private ViewFlipper pkRankVf; private ImageView mPkRankIcon; private TextView mPkRankText; + private ImageView mPkRankTopIcon; + private TextView mRedVal, mBlueVal; + private String pkUid = ""; public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { super(context, parentView); @@ -776,6 +780,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mGoodNumberIcon = (ImageView) findViewById(R.id.good_nub_ico); pkRankLayout = (LinearLayout) findViewById(R.id.live_rank_pk); pkRankVf = (ViewFlipper) findViewById(R.id.rank_pk_vf); + mPkRankTopIcon = (ImageView) findViewById(R.id.icon_pk_top); + mRedVal = (TextView) findViewById(R.id.pk_rank_red_val); + mBlueVal = (TextView) findViewById(R.id.pk_rank_blue_val); if (LivePushTxViewHolder.mTRTCCloud != null || LivePushRyViewHolder.rtcRoom != null) { fans_btn.setVisibility(View.GONE); @@ -791,9 +798,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); findViewById(R.id.hot_btn).setOnClickListener(this); try { - Glide.with(mContext).asGif().load(R.drawable.fans_medal).into(mViewMedal); + ImgLoader.displayGif(mContext, R.drawable.fans_medal, mViewMedal); } catch (Exception e) { - System.err.println("发生异常行为"); e.printStackTrace(); } @@ -1041,6 +1047,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis if (mContext instanceof LiveRyAnchorActivity) { findViewById(R.id.open_sidebar).setVisibility(View.GONE); findViewById(R.id.btn_follow).setVisibility(View.GONE); + findViewById(R.id.live_rank_pk).setVisibility(View.GONE); } else { configBanner3(); } @@ -1506,16 +1513,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private void initPkRank() { API.get().pdLiveApi(mContext) - .getPkRanksList(mLiveUid) + .getPkRanksList(mLiveUid, pkUid) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(listResponseModel -> { PkRankBean bean = listResponseModel.getData().getInfo(); - + ToastUtil.show("触发PK排位赛"); + Log.i("PK", bean.toString()); if (bean != null) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(20), DpUtil.dp2px(22)); LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - params.leftMargin=DpUtil.dp2px(2); + params.leftMargin = DpUtil.dp2px(2); textParams.setMarginStart(DpUtil.dp2px(1)); View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null); @@ -1532,6 +1540,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis pkRankVf.addView(titleIcon); pkRankVf.addView(hourView); pkRankVf.startFlipping(); + + mRedVal.setText(bean.getRedVal()+"連勝"); + mBlueVal.setText(bean.getBlueVal()+"連勝"); + //ImgLoader.display(mContext,bean.getPkTopImgUrl(),mPkRankTopIcon); } }, Throwable::printStackTrace) .isDisposed(); @@ -1686,7 +1698,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } //头像显示 - public static void setHeadData(LivePKUserListBean bean) { + public void setHeadData(LivePKUserListBean bean) { livePKUserListBean = bean; String mLiveuid = LiveRoomViewHolder.mLiveUid; if (livePKUserListBean != null) { @@ -1739,7 +1751,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } //双人pk显示 - public static void UpPkTwo() { + public void UpPkTwo() { ScreenDimenUtil util = ScreenDimenUtil.getInstance(); int mScreenWdith = util.getScreenWdith(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams(); @@ -1747,6 +1759,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis lt_pk_line.requestLayout(); lt_pk_line.setVisibility(View.VISIBLE); + mPkRankTopIcon.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((LiveActivity) Contexts, "", avatar_l1); @@ -1762,12 +1775,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis uidR2 = ""; uidR1 = ""; uidR3 = ""; + + initPkRank(); } //双人pk关闭 - public static void closePkTwo() { + public void closePkTwo() { + mPkRankTopIcon.setVisibility(View.GONE); lt_pk_line.setVisibility(View.GONE); livePKUserListBean = new LivePKUserListBean(); + pkUid=""; } /** @@ -3524,9 +3541,22 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } @Subscribe(threadMode = ThreadMode.MAIN) - public void imUpdatePkRank(PkRankBean bean) { - if (bean != null) { - updatePkRank(bean); + public void updateSub(LiveAudienceEvent event) { + switch (event.getType()) { + case PK_RANK_UPDATE: + updatePkRank((PkRankBean) event.getObject()); + break; + case PK_TWO_UPDATE_HEAD_DATA: + setHeadData((LivePKUserListBean) event.getObject()); + break; + case PK_TWO_START: + pkUid = event.getObject().toString(); + UpPkTwo(); + break; + case PK_TWO_END: + closePkTwo(); + break; } + } } diff --git a/live/src/main/res/drawable/bg_live_item_pk_rank_blue.xml b/live/src/main/res/drawable/bg_live_item_pk_rank_blue.xml new file mode 100644 index 000000000..87dbd29ee --- /dev/null +++ b/live/src/main/res/drawable/bg_live_item_pk_rank_blue.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_live_item_pk_rank_red.xml b/live/src/main/res/drawable/bg_live_item_pk_rank_red.xml new file mode 100644 index 000000000..20019514e --- /dev/null +++ b/live/src/main/res/drawable/bg_live_item_pk_rank_red.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 760fb8a0a..49a08a858 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -488,7 +488,6 @@ + android:gravity="center" + android:visibility="invisible"> + android:focusable="true" + android:visibility="visible"> - @@ -1242,14 +1241,17 @@ + + android:layout_centerHorizontal="true" + android:layout_marginTop="40dp" + android:src="@mipmap/icon_rank_top_box" + android:visibility="gone" /> + + + + +