新增PK TOP

This commit is contained in:
zlzw 2022-11-16 11:27:44 +08:00
parent 45257e8fe1
commit 9b37374066
12 changed files with 188 additions and 34 deletions

View File

@ -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);

View File

@ -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 + '\'' +
'}';
}
}

View File

@ -268,5 +268,5 @@ public interface PDLiveApi {
* PK排位赛接口
*/
@GET("/api/public/?service=Ranking.getAnchorRankData")
Observable<ResponseModel<PkRankBean>> getPkRanksList(@Query("anchor_id") String anchorId);
Observable<ResponseModel<PkRankBean>> getPkRanksList(@Query("anchor_id") String anchorId,@Query("anchor_id2")String pkUid);
}

View File

@ -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腾讯

View File

@ -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;

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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) {
@ -497,7 +500,7 @@ public class LiveLinkMicPkViewHolder extends AbsViewHolder {
animationDrawable.stop();
}
LiveRoomViewHolder.closePkTwo();
EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_END));
}
public void setIsAnchor(boolean flag) {

View File

@ -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;
}
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="80dp" android:height="30dp">
<shape android:shape="rectangle">
<solid android:color="#CC6171ff" />
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp" android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="80dp" android:height="30dp">
<shape android:shape="rectangle">
<solid android:color="#CCfb4b47" />
<corners android:topLeftRadius="15dp" android:topRightRadius="15dp" android:bottomLeftRadius="15dp" android:bottomRightRadius="15dp" />
</shape>
</item>
</selector>

View File

@ -488,7 +488,6 @@
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:id="@+id/open_sidebar"
android:layout_width="65dp"
android:layout_height="20dp"
@ -497,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">
<ImageView
android:layout_width="8dp"
@ -516,15 +516,15 @@
</LinearLayout>
<LinearLayout
android:visibility="visible"
android:id="@+id/live_rank_pk"
android:layout_width="80dp"
android:layout_height="20dp"
android:background="@drawable/bg_live_item_pk_rank"
android:layout_alignTop="@id/hour_rank_layout"
android:layout_alignParentRight="true"
android:background="@drawable/bg_live_item_pk_rank"
android:clickable="true"
android:focusable="true">
android:focusable="true"
android:visibility="visible">
<ViewFlipper
@ -536,7 +536,6 @@
android:outAnimation="@anim/anim_marquee_out" />
</LinearLayout>
@ -1242,14 +1241,17 @@
</FrameLayout>
</FrameLayout>
<ImageView
android:id="@+id/icon_pk_top"
android:src="@mipmap/icon_rank_top_box"
android:layout_width="130dp"
android:layout_marginTop="40dp"
android:layout_centerHorizontal="true"
android:layout_height="35dp"
android:layout_alignTop="@+id/live_video"
android:layout_height="35dp"/>
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:src="@mipmap/icon_rank_top_box"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/lt_pk_line"
android:layout_width="match_parent"
@ -1257,7 +1259,41 @@
android:layout_marginTop="@dimen/live_top"
android:visibility="gone">
<TextView
android:id="@+id/pk_rank_red_val"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/pk_red_layout"
android:layout_marginStart="13dp"
android:layout_marginBottom="10dp"
android:background="@drawable/bg_live_item_pk_rank_red"
android:paddingStart="17dp"
android:paddingTop="8dp"
android:paddingEnd="17dp"
android:paddingBottom="8dp"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/pk_rank_blue_val"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/pk_red_layout"
android:layout_alignParentEnd="true"
android:layout_marginEnd="13dp"
android:layout_marginBottom="10dp"
android:background="@drawable/bg_live_item_pk_rank_blue"
android:paddingStart="17dp"
android:paddingTop="8dp"
android:paddingEnd="17dp"
android:paddingBottom="8dp"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/pk_red_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">