跨房PK:PK记分面板

This commit is contained in:
huangjian
2021-11-10 19:18:32 +08:00
parent a0e3d78894
commit 5c99b5bf6b
43 changed files with 1513 additions and 495 deletions

View File

@@ -89,6 +89,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomGiftValueAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomInfoAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTipAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RouterType;
import com.yizhuan.xchat_android_core.im.custom.bean.SysMsgAttachment;
@@ -240,6 +241,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_ROOM_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_QUEUING_MIC;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
@@ -270,6 +272,9 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_QUEUING_MIC_NON_EMPTY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_ACCEPT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_INVITE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_UPDATA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_MONSTER_HUNTING;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ADD_BLACK;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_KICK_ROOM;
@@ -1330,6 +1335,22 @@ public final class IMNetEaseManager {
if (second == CUSTOM_MSG_SUB_DATING_Al_NOTIFY) {
noticeRoomEvent(msg, RoomEvent.DATING_ALL_NOTIFY);
}
break;
case CUSTOM_MSG_ROOM_PK:
RoomPKAttachment roomPKAttachment = (RoomPKAttachment) msg.getAttachment();
switch (second){
case CUSTOM_MSG_SUB_ROOM_PK_INVITE:
noticeRoomEvent(msg, RoomEvent.ROOM_PK_INVITE);
break;
case CUSTOM_MSG_SUB_ROOM_PK_ACCEPT:
noticeRoomEvent(msg, RoomEvent.ROOM_PK_ACCEPT);
AvRoomDataManager.get().roomPkLiveData.postValue(roomPKAttachment.getRoomPkBean());
break;
case CUSTOM_MSG_SUB_ROOM_PK_UPDATA:
AvRoomDataManager.get().roomPkLiveData.postValue(roomPKAttachment.getRoomPkBean());
break;
}
break;
default:
break;

View File

@@ -557,6 +557,9 @@ public class CustomAttachParser implements MsgAttachmentParser {
case CustomAttachment.CUSTOM_MSG_MATCH_TICKET:
attachment = new MatchTicketAttachment(second);
break;
case CustomAttachment.CUSTOM_MSG_ROOM_PK:
attachment = new RoomPKAttachment(second);
break;
default:
break;
}

View File

@@ -393,9 +393,11 @@ public class CustomAttachment implements MsgAttachment {
public static final int CUSTOM_MSG_CHAT_HINT = 75;
public static final int CUSTOM_MSG_SUB_CHAT_HINT = 751;
//私聊提示
//跨房PK
public static final int CUSTOM_MSG_ROOM_PK = 83;
public static final int CUSTOM_MSG_SUB_ROOM_PK_INVITE = 831;
public static final int CUSTOM_MSG_SUB_ROOM_PK_ACCEPT = 832;
public static final int CUSTOM_MSG_SUB_ROOM_PK_UPDATA = 834;
public CustomAttachment() {

View File

@@ -0,0 +1,31 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
public class RoomPKAttachment extends CustomAttachment {
private RoomPkBean roomPkBean;
public RoomPKAttachment(int second) {
super(CUSTOM_MSG_ROOM_PK, second);
}
public RoomPkBean getRoomPkBean() {
return roomPkBean;
}
public void setRoomPkBean(RoomPkBean roomPkBean) {
this.roomPkBean = roomPkBean;
}
@Override
protected void parseData(JSONObject data) {
roomPkBean = new Gson().fromJson(data.toJSONString(), RoomPkBean.class);
}
@Override
protected JSONObject packData() {
return null;
}
}

View File

@@ -0,0 +1,97 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
@Data
public class RoomPkBean implements Serializable {
/**
* PK时长
**/
private long pkDuration;
/**
* 邀请房间标题
**/
private String inviteRoomTitle;
/**
* 邀请房间uid
**/
private long inviteUid;
/**
* PK玩法
**/
private String pkDesc;
/**
* PK轮次Id
**/
private String roundId;
/**
* 是否初始化
*/
private boolean isInit;
/**
* 是否提前/强制结束
*/
private boolean isForce;
/**
* 倒计时开始时间点:时间戳
*/
private long endTime;
/**
* 胜利方房主uid
*/
private long winUid;
//房间总流水
private long allAmount;
//当前方房主uid
private long cUid;
//当前方房主头像
private String cAvatar;
//当前方房间名称
private String cTitle;
//当前方流水
private long cAmount;
//比例:0-100当前方进度条比率
private double cPercent;
//当前神豪榜前三
private List<RankBean> csRank;
//当前魅力榜前三
private List<RankBean> crRank;
//另一方方房主uid
private long aUid;
//另一方房主头像
private String aAvatar;
//另一方房间名称
private String aTitle;
//另一方流水
private long aAmount;
//比例:0-100另一方进度条比率
private String aPercent;
//另一方神豪榜前三
private List<RankBean> asRank;
//另一方魅力榜前三
private List<RankBean> arRank;
@Data
public static class RankBean implements Serializable{
//uid
private long uid;
//昵称
private String nick;
//头像
private String avatar;
//性别
private int gender;
//贡献值/魅力值
private String amount;
}
}

View File

@@ -9,6 +9,7 @@ import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.MutableLiveData;
import com.netease.nimlib.sdk.NIMChatRoomSDK;
import com.netease.nimlib.sdk.RequestCallback;
@@ -23,6 +24,7 @@ import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.netease.nimlib.sdk.msg.constant.NotificationType;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean;
import com.yizhuan.xchat_android_core.room.bean.BoxSwitchVo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.room.bean.SimplePartyRoomInfo;
@@ -178,6 +180,8 @@ public final class AvRoomDataManager {
public boolean roomNoDestory;
public List<String> phrases = new ArrayList<>(Arrays.asList("萌新求关注!", "你们在聊什么呀?", "这个怎么玩呀?", "我要上麦"));
public final MutableLiveData<RoomPkBean> roomPkLiveData = new MutableLiveData<>();
private static final class Helper {
private static final AvRoomDataManager INSTANCE = new AvRoomDataManager();
@@ -474,6 +478,11 @@ public final class AvRoomDataManager {
return mCurrentRoomInfo != null && mCurrentRoomInfo.getRoomModeType() == RoomModeType.OPEN_PK_MODE;
}
public boolean isOpenAnotherPKMode() {
return mCurrentRoomInfo != null && mCurrentRoomInfo.getRoomModeType() == RoomModeType.OPEN_ANOTHER_PK_MODE;
}
/**
* 是否是房间管理员
*

View File

@@ -207,8 +207,13 @@ public class RoomEvent {
public static final int BOX_NOTIFY_SVGA = 69;
public static final int DATING_PUBLISH_RESULT = 70;
public static final int DATING_ALL_NOTIFY = 71;
public static final int ROOM_PK_INVITE = 72;
public static final int ROOM_PK_ACCEPT = 73;
private int event = NONE;
private int micPosition = Integer.MIN_VALUE;
private int posState = -1;

View File

@@ -1,6 +1,7 @@
package com.yizhuan.xchat_android_core.room.anotherroompk
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean
import com.yizhuan.xchat_android_core.utils.net.RxHelper
import com.yizhuan.xchat_android_library.net.rxnet.RxNet
import io.reactivex.Single
@@ -49,7 +50,7 @@ object RoomPKModel {
fun acceptRoomPK(
isAccept: Boolean,
roomUid: Long,
roundId: Long
roundId: String
): Single<String> {
return api.acceptRoomPK(isAccept, roomUid, roundId)
.compose(RxHelper.handleSchAndExce())
@@ -75,6 +76,21 @@ object RoomPKModel {
.compose(RxHelper.handleBeanData())
}
/**
* 跨房pk/牌照房搜索
*
* @param roomUid roomUid
*
* @return
*/
fun getRoomPKData(
roomUid: Long
): Single<RoomPkBean> {
return api.getRoomPKData(roomUid)
.compose(RxHelper.handleSchAndExce())
.compose(RxHelper.handleBeanData())
}
private interface Api {
/**
* 发起挑战
@@ -97,11 +113,11 @@ object RoomPKModel {
* @return
*/
@FormUrlEncoded
@POST("/crossroompkround/initiateChallenge")
@POST("/crossroompkround/replyChallenge")
fun acceptRoomPK(
@Field("isAccept") isAccept: Boolean,
@Field("roomUid") roomUid: Long,
@Field("roundId") roundId: Long
@Field("roundId") roundId: String
): Single<ServiceResult<String>>
/**
@@ -117,6 +133,18 @@ object RoomPKModel {
@Query("pageSize") pageSize: Int
): Single<ServiceResult<List<SimpleRoomInfo>>>
/**
*
* 获取PK数据
*
* @return
*/
@FormUrlEncoded
@POST("/crossroompkround/getCrossPkData")
fun getRoomPKData(
@Field("roomUid") roomUid: Long?
): Single<ServiceResult<RoomPkBean>>
}

View File

@@ -9,4 +9,5 @@ public interface RoomModeType {
int CLOSE_MICRO_MODE = 2; //关闭排麦模式
int OPEN_PK_MODE = 3;//开启PK模式
int OPEN_DATING_MODE = 5;//开启相亲模式
int OPEN_ANOTHER_PK_MODE = 7;//开启跨房PK模式
}

View File

@@ -525,10 +525,10 @@ public class StatisticsProtocol {
EVENT_HOME_INTO_FOLLOW_ROOM_CLICK("home_intofollowroom"),//首页_进入收藏房间
EVENT_HOME_INTO_CHAT_ROOM_CLICK("home_intochatroom"),//首页_进入聊天交友房间
EVENT_HOME_INTO_JYKL_ROOM_CLICK("JYKL_intoroom "),//点击交友扩列项进入房间
EVENT_HOME_INTO_TJFJ_ROOM_CLICK("TJFJ_intoroom "),//点击推荐房间进入房间
EVENT_HOME_INTO_LTJY_ROOM_CLICK("LTJY_intoroom "),//点击聊天交友项进入房间
EVENT_HOME_INTO_DBRUK_CLICK("DBRUK_intoroom "),//点击顶部我的房间/关注进入房间
EVENT_HOME_INTO_JYKL_ROOM_CLICK("JYKL_intoroom"),//点击交友扩列项进入房间
EVENT_HOME_INTO_TJFJ_ROOM_CLICK("TJFJ_intoroom"),//点击推荐房间进入房间
EVENT_HOME_INTO_LTJY_ROOM_CLICK("LTJY_intoroom"),//点击聊天交友项进入房间
EVENT_HOME_INTO_DBRUK_CLICK("DBRUK_intoroom"),//点击顶部我的房间/关注进入房间
EVENT_MORE_ROOM_INTO_ROOM_CLICK("moreroom_intoroom"),//更多房间页_进入房间
EVENT_ME_INTO_MY_ROOM_CLICK("me_intomyroom"),//我页_进入我的房间