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/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 6625e23cc..aa5c3c898 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -169,6 +169,7 @@ public class Constants { public static final String AI_AUTOMATIC_SPEECH = "aiAutomaticSpeech";//机器人助手 public static final String STAR_CHALLENGE_UPGRADE_NOTIFY = "starChallengeUpgradeNotify";//星级挑战成功 public static final String SUPER_VISION = "supervision";//超级发言警告 + public static final String PK_RANK_UPDATE = "RankingRankUpdate";//PK排位赛更新数据 //游戏socket public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 diff --git a/common/src/main/java/com/yunbao/common/bean/PkRankBean.java b/common/src/main/java/com/yunbao/common/bean/PkRankBean.java new file mode 100644 index 000000000..16a3e90e8 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/PkRankBean.java @@ -0,0 +1,88 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; +import com.yunbao.common.utils.StringUtil; + +/** + * 直播间PK排位赛 + */ +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; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImg() { + return img; + } + + 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/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java index d936265d7..15ef5591a 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -29,7 +29,7 @@ public class ImgLoader { private static final boolean SKIP_MEMORY_CACHE = true; private static BlurTransformation sBlurTransformation; - private final static float thumbnail = 0.1f; + private final static float thumbnail = 1.0f; static { sBlurTransformation = new BlurTransformation(25); 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 bf6fccf34..8ebe3d505 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -14,6 +14,7 @@ import com.yunbao.common.bean.MsgSwitchDetailModel; import com.yunbao.common.bean.NewPeopleInfo; import com.yunbao.common.bean.NobleRankHideUserListModel; import com.yunbao.common.bean.NobleTrumpetModel; +import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.SearchModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SlideInBannerModel; @@ -262,4 +263,10 @@ public interface PDLiveApi { */ @GET("/api/public/?service=Task.sendTaskGift") Observable>> sendTaskGift(@Query("flag") String flag, @Query("type") String type); + + /** + * PK排位赛接口 + */ + @GET("/api/public/?service=Ranking.getAnchorRankData") + Observable> getPkRanksList(@Query("anchor_id") String anchorId,@Query("anchor_id2")String pkUid); } diff --git a/common/src/main/res/mipmap-mdpi/icon_pk_rank.png b/common/src/main/res/mipmap-mdpi/icon_pk_rank.png new file mode 100644 index 000000000..afb95207b Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_pk_rank.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_rank_top_box.png b/common/src/main/res/mipmap-mdpi/icon_rank_top_box.png new file mode 100644 index 000000000..25e96cfa4 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_rank_top_box.png differ 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..d5571c190 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腾讯 @@ -706,7 +706,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 主播与主播PK 所有人收到PK开始的回调 */ @Override - public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname) { + public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname,String isLadders) { Log.e("ry", "pkUid" + pkUid + "pkhead" + pkhead + "pkname" + pkname); if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); @@ -718,6 +718,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL Log.e("tasdsdg", mLiveUid + "1111" + CommonAppConfig.getInstance().getUid()); if (!mLiveUid.equals(CommonAppConfig.getInstance().getUid())) { mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); + mLiveRoomViewHolder.initPkRank(isLadders); } } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index 8e03f5bd0..f121c7aee 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -430,7 +430,6 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On if (dress.getJSONArray("wraps").size() >= 1) { JSONObject display = (JSONObject) dress.getJSONArray("wraps").get(0); - shawl.setTag("test"); ImgLoader.display(mContext, display.getString("display_src"), shawl); } if (dress.getJSONArray("avatar_frame").size() == 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 7177d2ddd..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, "底部合集"), @@ -174,7 +184,11 @@ public class LiveAudienceEvent extends BaseModel { LUCKY_ANGEL(31, "幸运天使"), WE_CHEAT(32, "整蛊"), WISH_LIST_UPDATE(33, "心愿单更新推送"), - UN_LEAVELIVE(34, "取消暂时离开") + UN_LEAVELIVE(34, "取消暂时离开"), + 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/SocketClient.java b/live/src/main/java/com/yunbao/live/socket/SocketClient.java index 04db014d1..1752860c3 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketClient.java @@ -763,13 +763,13 @@ public class SocketClient { break; case 2://收到对方确认主播PK回调 mListener.onLinkMicToPk(map.getString("uid"), map.getString("pkhead"), map.getString("pkname")); - mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname")); + mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"),map.getString("is_ladders")); break; case 3://对方主播拒绝PK的回调 mListener.onLinkMicPkRefuse(); break; case 4://所有人收到PK开始址的回调 - mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname")); + mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"),map.getString("is_ladders")); break; case 5://PK时候断开连麦的回调 if (LivePushTxViewHolder.mTRTCCloud != null) { diff --git a/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java b/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java index fe4426d69..664feb37f 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java @@ -247,7 +247,7 @@ public interface SocketMessageListener { /** * 主播与主播PK 所有人收到PK开始的回调 */ - void onLinkMicPkStart(String pkUid, String pkhead, String pkname); + void onLinkMicPkStart(String pkUid, String pkhead, String pkname,String isLadders); /** * 主播与主播PK 断开连麦pk的回调 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 35ba07be9..098d32eb9 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -24,6 +24,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.FansMedalBean; import com.yunbao.common.bean.MsgModel; +import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.SocketModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; @@ -515,6 +516,17 @@ public class SocketRyClient { .setType(LiveAudienceEvent.LiveAudienceType.LUCKY_ANGEL) .setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class))); break; + case Constants.PK_RANK_UPDATE: + Log.i("PK排位",map.toString()); + JSONObject item=map.getJSONObject("ct"); + PkRankBean pkRankBean=new PkRankBean(); + 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(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_UPDATE) + .setObject(pkRankBean)); + break; } } @@ -980,7 +992,7 @@ public class SocketRyClient { */ private static void processAnchorLinkMicPk(JSONObject map) { int action = map.getIntValue("action"); - Log.i("Socket", "action = "+action+" json = "+map.toString()); + Log.i("Socket", "action = " + action + " json = " + map.toString()); switch (action) { case 1://收到对方主播PK回调 @@ -992,13 +1004,13 @@ public class SocketRyClient { break; case 2://收到对方主播PK回调 mListener.onLinkMicToPk(map.getString("uid"), map.getString("pkhead"), map.getString("pkname")); - mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"));// mListener.onLinkMicPkStart(map.getString("uid")); + mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"),map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); break; case 3://对方主播拒绝PK的回调 mListener.onLinkMicPkRefuse(); break; case 4://所有人收到PK开始址的回调 - mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname")); + mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"),map.getString("is_ladders")); break; case 5://PK时候断开连麦的回调 if (rtcRoom != 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 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 320707f6a..ca2da5816 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -70,6 +70,7 @@ import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveGiftBean; import com.yunbao.common.bean.LiveRoomActivityBanner; import com.yunbao.common.bean.MsgModel; +import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; @@ -90,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; @@ -274,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; @@ -307,6 +309,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private FullServiceNotificationView fullScreen;//全副喇叭 private NobleNoticeView noble;//全副喇叭 private FaceManager manager; + private LinearLayout pkRankLayout; + 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); @@ -769,6 +778,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis wishListLayout = (LinearLayout) findViewById(R.id.wish_list_layout); mAnchorLayout = (LinearLayout) findViewById(R.id.group_1); 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); @@ -784,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(); } @@ -1034,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(); } @@ -1056,16 +1070,19 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); } - public void clearChat(){ - if(mLiveChatAdapter!=null){ + + public void clearChat() { + if (mLiveChatAdapter != null) { mLiveChatAdapter.clear(); } } - public void clearGuardIcon(){ - if(userGuard!=null){ + + public void clearGuardIcon() { + if (userGuard != null) { userGuard.setImageResource(R.mipmap.img_guardian_empty); } } + public synchronized void showStart(StarChallengeStatusModel data) { boolean upData = false; if (mBannerList2 != null && mBannerList2.size() == 0) { @@ -1491,6 +1508,70 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }, Throwable::printStackTrace) .isDisposed(); + initPkRank(); + } + + private void initPkRankView() { + if(pkRankVf.getTag()!=null){ + return; + } + 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); + textParams.setMarginStart(DpUtil.dp2px(1)); + + View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null); + ImageView titleIcon = new ImageView(mContext); + mPkRankIcon = hourView.findViewById(R.id.wish_pic); + mPkRankText = hourView.findViewById(R.id.wish_index); + mPkRankText.setLayoutParams(textParams); + mPkRankText.setGravity(Gravity.CENTER); + titleIcon.setImageResource(R.mipmap.icon_pk_rank); + titleIcon.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + mPkRankIcon.setLayoutParams(params); + pkRankVf.addView(titleIcon); + pkRankVf.addView(hourView); + pkRankVf.startFlipping(); + pkRankVf.setTag("start"); + } + + private void initPkRank() { + initPkRank(null); + } + + public void initPkRank(String isLadders) { + API.get().pdLiveApi(mContext) + .getPkRanksList(mLiveUid, pkUid) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(listResponseModel -> { + PkRankBean bean = listResponseModel.getData().getInfo(); + if (bean != null) { + Log.i("PK", bean.toString() + " | " + isLadders); + initPkRankView(); + + mPkRankText.setText(bean.getName()); + ImgLoader.display(mContext, bean.getImg(), mPkRankIcon); + if (StringUtil.isEmpty(bean.getPkTopImgUrl()) || StringUtil.isEmpty(isLadders)) { + return; + } + if (!StringUtil.isEmpty(isLadders)) { + bean.setPkTopImgUrl(isLadders); + } + if (Integer.parseInt(bean.getRedVal()) > 2) { + mRedVal.setVisibility(View.VISIBLE); + mRedVal.setText(bean.getRedVal() + "連勝"); + } + if (Integer.parseInt(bean.getBlueVal()) > 2) { + mBlueVal.setVisibility(View.VISIBLE); + mBlueVal.setText(bean.getBlueVal() + "連勝"); + } + mPkRankTopIcon.setVisibility(View.VISIBLE); + ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon); + } + }, Throwable::printStackTrace) + .isDisposed(); + } /** @@ -1523,6 +1604,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + private void updatePkRank(PkRankBean bean) { + mPkRankText.setText(bean.getName()); + ImgLoader.display(mContext, bean.getImg(), mPkRankIcon); + initPkRank(); + } + /** * 设置热度值 * @@ -1636,7 +1723,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) { @@ -1689,7 +1776,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(); @@ -1715,9 +1802,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } //双人pk关闭 - public static void closePkTwo() { + public void closePkTwo() { + mPkRankTopIcon.setVisibility(View.GONE); lt_pk_line.setVisibility(View.GONE); livePKUserListBean = new LivePKUserListBean(); + pkUid = ""; } /** @@ -3472,4 +3561,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveChatAdapter.insertItem(bean); } } + + @Subscribe(threadMode = ThreadMode.MAIN) + 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(); + initPkRank(); + break; + case PK_TWO_END: + closePkTwo(); + break; + } + + } } 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 339e3c83b..c0b64f482 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -923,7 +923,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } @Override - public void onLinkMicPkStart(String pkUid, String pkhead, String pkname) { + public void onLinkMicPkStart(String pkUid, String pkhead, String pkname,String isLadders) { if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); Handler handler = new Handler(); @@ -934,6 +934,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe Log.e("tasdsdg", liveID + "1111" + CommonAppConfig.getInstance().getUid()); if (!liveID.equals(CommonAppConfig.getInstance().getUid())) { mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); + mLiveRoomViewHolder.initPkRank(isLadders); } } } diff --git a/live/src/main/res/drawable/bg_live_item_pk_rank.xml b/live/src/main/res/drawable/bg_live_item_pk_rank.xml new file mode 100644 index 000000000..220b6230d --- /dev/null +++ b/live/src/main/res/drawable/bg_live_item_pk_rank.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file 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 b6fe3828a..a00d8eec5 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -496,7 +496,8 @@ android:background="@drawable/bg_live_item_right" android:clickable="true" android:focusable="true" - android:gravity="center"> + android:gravity="center" + android:visibility="invisible"> + + + + + + + + + + + + + +