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..67af66531 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/PkRankBean.java @@ -0,0 +1,39 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +/** + * 直播间PK排位赛 + */ +public class PkRankBean extends BaseModel{ + @SerializedName("anchor_id") + public int id; + @SerializedName("rank_name") + public String name; + @SerializedName("rank_img") + public String img; + + 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; + } +} 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 0b42fddcd..f1d73bb6b 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); } 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/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..88cd47779 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -174,7 +174,8 @@ 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排位赛更新") ; private int type; 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..b02dc58d8 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,15 @@ 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(pkRankBean); + break; } } @@ -980,7 +990,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回调 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..59693cb4f 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; @@ -307,6 +308,10 @@ 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; public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { super(context, parentView); @@ -769,6 +774,8 @@ 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); if (LivePushTxViewHolder.mTRTCCloud != null || LivePushRyViewHolder.rtcRoom != null) { fans_btn.setVisibility(View.GONE); @@ -1056,16 +1063,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 +1501,40 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }, Throwable::printStackTrace) .isDisposed(); + initPkRank(); + } + + private void initPkRank() { + API.get().pdLiveApi(mContext) + .getPkRanksList(mLiveUid) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(listResponseModel -> { + PkRankBean bean = listResponseModel.getData().getInfo(); + + if (bean != null) { + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DpUtil.dp2px(44), DpUtil.dp2px(16)); + LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + textParams.leftMargin = DpUtil.dp2px(5); + + 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.setText(bean.getName()); + mPkRankText.setLayoutParams(textParams); + mPkRankText.setGravity(Gravity.CENTER); + titleIcon.setImageResource(R.mipmap.icon_pk_rank); + ImgLoader.display(mContext, bean.getImg(), mPkRankIcon); + titleIcon.setLayoutParams(params); + mPkRankIcon.setLayoutParams(params); + pkRankVf.addView(titleIcon); + pkRankVf.addView(hourView); + pkRankVf.startFlipping(); + } + }, Throwable::printStackTrace) + .isDisposed(); + } /** @@ -1523,6 +1567,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + private void updatePkRank(PkRankBean bean) { + mPkRankText.setText(bean.getName()); + ImgLoader.display(mContext, bean.getImg(), mPkRankIcon); + } + /** * 设置热度值 * @@ -3472,4 +3521,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mLiveChatAdapter.insertItem(bean); } } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void imUpdatePkRank(PkRankBean bean) { + if (bean != null) { + updatePkRank(bean); + } + } } 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/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index b6fe3828a..993205bcd 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -488,6 +488,7 @@ + + + + + + + + +