个播房新增向下滑动切换房间功能

This commit is contained in:
huangjian
2022-07-13 18:59:42 +08:00
parent 0ac0464533
commit 17daa8ac83
11 changed files with 531 additions and 289 deletions

View File

@@ -481,8 +481,9 @@ public final class IMNetEaseManager {
MLog.info(TAG, "登录中...");
} else if (chatRoomStatusChangeData.status == StatusCode.LOGINED) {
MLog.info(TAG, "云信聊天室已登录成功");
noticeImNetReLogin(mCacheRoomQueueInfo);
if (mCacheRoomQueueInfo != null) {
noticeImNetReLogin(mCacheRoomQueueInfo);
}
Map<String, String> parans = new HashMap<>(3);
parans.put("user_id", String.valueOf(currentUid));
parans.put("net_type", NetworkUtils.getNetworkTypeName(BasicConfig.INSTANCE.getAppContext()));
@@ -1316,10 +1317,10 @@ public final class IMNetEaseManager {
UserModel.get().getCacheLoginUserInfo().setGroupType(PKTeamInfo.TEAM_NONE);
//在麦上就更新信息
AvRoomModel.get().updateMyMicQueue(
AvRoomDataManager.get().getMicPosition(AuthModel.get().getCurrentUid()),
String.valueOf(AvRoomDataManager.get().mCurrentRoomInfo.getRoomId()),
UserModel.get().getCacheLoginUserInfo()
)
AvRoomDataManager.get().getMicPosition(AuthModel.get().getCurrentUid()),
String.valueOf(AvRoomDataManager.get().mCurrentRoomInfo.getRoomId()),
UserModel.get().getCacheLoginUserInfo()
)
.subscribe();
}
}
@@ -2002,31 +2003,31 @@ public final class IMNetEaseManager {
public Single<List<ChatRoomMember>> fetchRoomMembersByIds(final List<String> accounts) {
return Single.create((SingleOnSubscribe<List<ChatRoomMember>>) e -> {
final RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (mCurrentRoomInfo == null || ListUtils.isListEmpty(accounts)) {
e.onError(new IllegalArgumentException("RoomInfo is null or accounts is null"));
return;
}
NIMChatRoomSDK.getChatRoomService()
.fetchRoomMembersByIds(String.valueOf(mCurrentRoomInfo.getRoomId()), accounts)
.setCallback(new RequestCallback<List<ChatRoomMember>>() {
@Override
public void onSuccess(List<ChatRoomMember> param) {
e.onSuccess(param);
}
final RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (mCurrentRoomInfo == null || ListUtils.isListEmpty(accounts)) {
e.onError(new IllegalArgumentException("RoomInfo is null or accounts is null"));
return;
}
NIMChatRoomSDK.getChatRoomService()
.fetchRoomMembersByIds(String.valueOf(mCurrentRoomInfo.getRoomId()), accounts)
.setCallback(new RequestCallback<List<ChatRoomMember>>() {
@Override
public void onSuccess(List<ChatRoomMember> param) {
e.onSuccess(param);
}
@Override
public void onFailed(int code) {
e.onError(new Exception("错误码: " + code));
}
@Override
public void onFailed(int code) {
e.onError(new Exception("错误码: " + code));
}
@Override
public void onException(Throwable exception) {
e.onError(exception);
}
});
@Override
public void onException(Throwable exception) {
e.onError(exception);
}
});
}).subscribeOn(Schedulers.computation())
}).subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread());
}
@@ -2242,16 +2243,16 @@ public final class IMNetEaseManager {
if (roomInfo == null) return null;
String downMicUid = AvRoomDataManager.get().getRoomQueueMemberUidByMicPosition(micPosition);
return Single.create((SingleOnSubscribe<String>) e -> {
RequestResult<Entry<String, String>> result = NIMClient.syncRequest(NIMChatRoomSDK.getChatRoomService()
.pollQueue(String.valueOf(roomInfo.getRoomId()), String.valueOf(micPosition)));
if (result.exception != null)
e.onError(result.exception);
else if (result.code != BaseMvpModel.RESULT_OK)
e.onError(new Throwable("错误码: " + result.code));
else {
e.onSuccess("下麦回调成功");
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
RequestResult<Entry<String, String>> result = NIMClient.syncRequest(NIMChatRoomSDK.getChatRoomService()
.pollQueue(String.valueOf(roomInfo.getRoomId()), String.valueOf(micPosition)));
if (result.exception != null)
e.onError(result.exception);
else if (result.code != BaseMvpModel.RESULT_OK)
e.onError(new Throwable("错误码: " + result.code));
else {
e.onSuccess("下麦回调成功");
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.doOnSuccess(s -> GiftValueMrg.get().requestDownMic(micPosition, downMicUid));
}
@@ -2320,10 +2321,10 @@ public final class IMNetEaseManager {
@Override
public void subscribe(SingleEmitter<String> e) throws Exception {
NIMChatRoomSDK.getChatRoomService().kickMember(
String.valueOf(roomId),
String.valueOf(account),
notifyExtension
)
String.valueOf(roomId),
String.valueOf(account),
notifyExtension
)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
@@ -2429,28 +2430,28 @@ public final class IMNetEaseManager {
return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR));
final long micUid = baseInfo.getUid();
return Single.create(
new SingleOnSubscribe<ChatRoomMessage>() {
@Override
public void subscribe(SingleEmitter<ChatRoomMessage> e) throws Exception {
RoomQueueMsgAttachment queueMsgAttachment = new RoomQueueMsgAttachment(CUSTOM_MSG_HEADER_TYPE_QUEUE,
CUSTOM_MSG_HEADER_TYPE_QUEUE_INVITE);
new SingleOnSubscribe<ChatRoomMessage>() {
@Override
public void subscribe(SingleEmitter<ChatRoomMessage> e) throws Exception {
RoomQueueMsgAttachment queueMsgAttachment = new RoomQueueMsgAttachment(CUSTOM_MSG_HEADER_TYPE_QUEUE,
CUSTOM_MSG_HEADER_TYPE_QUEUE_INVITE);
queueMsgAttachment.uid = String.valueOf(micUid);
queueMsgAttachment.micPosition = position;
queueMsgAttachment.handleUid = AuthModel.get().getCurrentUid();
UserInfo myInfo = UserModel.get().getCacheLoginUserInfo();
if (myInfo != null) {
queueMsgAttachment.handleNick = myInfo.getNick() == null ? "" : myInfo.getNick();
}
queueMsgAttachment.targetNick = baseInfo.getNick();
if (baseInfo.getGroupType() != 0) {
queueMsgAttachment.groupType = baseInfo.getGroupType();
}
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), queueMsgAttachment);
e.onSuccess(message);
}
}).subscribeOn(Schedulers.io())
queueMsgAttachment.uid = String.valueOf(micUid);
queueMsgAttachment.micPosition = position;
queueMsgAttachment.handleUid = AuthModel.get().getCurrentUid();
UserInfo myInfo = UserModel.get().getCacheLoginUserInfo();
if (myInfo != null) {
queueMsgAttachment.handleNick = myInfo.getNick() == null ? "" : myInfo.getNick();
}
queueMsgAttachment.targetNick = baseInfo.getNick();
if (baseInfo.getGroupType() != 0) {
queueMsgAttachment.groupType = baseInfo.getGroupType();
}
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), queueMsgAttachment);
e.onSuccess(message);
}
}).subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.filter(new Predicate<ChatRoomMessage>() {
@Override
@@ -2537,17 +2538,17 @@ public final class IMNetEaseManager {
if (roomInfo == null)
return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR));
return Single.create(
(SingleOnSubscribe<ChatRoomMessage>) e -> {
NobleAttachment nobleMsgAttachment = new NobleAttachment(CUSTOM_MESS_HEAD_NOBLE,
CUSTOM_MESS_SUB_ROOM_WELCOME);
nobleMsgAttachment.uid = uid;
nobleMsgAttachment.nick = nick;
nobleMsgAttachment.nobleInfo = nobleInfo;
(SingleOnSubscribe<ChatRoomMessage>) e -> {
NobleAttachment nobleMsgAttachment = new NobleAttachment(CUSTOM_MESS_HEAD_NOBLE,
CUSTOM_MESS_SUB_ROOM_WELCOME);
nobleMsgAttachment.uid = uid;
nobleMsgAttachment.nick = nick;
nobleMsgAttachment.nobleInfo = nobleInfo;
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), nobleMsgAttachment);
e.onSuccess(message);
}).subscribeOn(Schedulers.io())
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), nobleMsgAttachment);
e.onSuccess(message);
}).subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.filter(chatRoomMessage -> nobleInfo != null && !TextUtils.isEmpty(nick) && uid != 0)
.toSingle()
@@ -2567,19 +2568,19 @@ public final class IMNetEaseManager {
if (roomInfo == null)
return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR));
return Single.create(
(SingleOnSubscribe<ChatRoomMessage>) e -> {
CarAttachment carAttachment = new CarAttachment(CUSTOM_MESS_HEAD_CAR,
CUSTOM_MESS_SUB_CAR_ENTER_ROOM);
carAttachment.uid = uid;
carAttachment.nick = nick;
carAttachment.effect = carInfo.getEffect();
carAttachment.viewUrl = carInfo.getViewUrl();
carAttachment.otherViewType = carInfo.getOtherViewType();
(SingleOnSubscribe<ChatRoomMessage>) e -> {
CarAttachment carAttachment = new CarAttachment(CUSTOM_MESS_HEAD_CAR,
CUSTOM_MESS_SUB_CAR_ENTER_ROOM);
carAttachment.uid = uid;
carAttachment.nick = nick;
carAttachment.effect = carInfo.getEffect();
carAttachment.viewUrl = carInfo.getViewUrl();
carAttachment.otherViewType = carInfo.getOtherViewType();
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), carAttachment);
e.onSuccess(message);
}).subscribeOn(Schedulers.io())
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), carAttachment);
e.onSuccess(message);
}).subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.filter(chatRoomMessage -> carInfo != null && !TextUtils.isEmpty(nick) && uid != 0)
.toSingle()
@@ -2664,28 +2665,28 @@ public final class IMNetEaseManager {
long delayTime, ReconnectListener listener) {
return Single.create((SingleOnSubscribe<RetryChatRoomMessage>) emitter -> {
retryChatRoomMessage.setRetryCount(retryChatRoomMessage.getRetryCount() + 1);
ImRetryManager.logIde("start send im msg :" + retryChatRoomMessage.getRetryCount());
if (isExitRoom()) {
String error = "exite room when send msg";
emitter.onError(new Throwable(error));
return;
}
if (isChangeRoom(retryChatRoomMessage.getMessage())) {
String error = "changed room when send msg";
emitter.onError(new Throwable(error));
return;
}
sendChatRoomMessage(retryChatRoomMessage.getMessage(), false)
.subscribe((message, throwable) -> {
if (throwable == null) {
retryChatRoomMessage.setMessage(message);
emitter.onSuccess(retryChatRoomMessage);
} else {
emitter.onError(throwable);
}
});
})
retryChatRoomMessage.setRetryCount(retryChatRoomMessage.getRetryCount() + 1);
ImRetryManager.logIde("start send im msg :" + retryChatRoomMessage.getRetryCount());
if (isExitRoom()) {
String error = "exite room when send msg";
emitter.onError(new Throwable(error));
return;
}
if (isChangeRoom(retryChatRoomMessage.getMessage())) {
String error = "changed room when send msg";
emitter.onError(new Throwable(error));
return;
}
sendChatRoomMessage(retryChatRoomMessage.getMessage(), false)
.subscribe((message, throwable) -> {
if (throwable == null) {
retryChatRoomMessage.setMessage(message);
emitter.onSuccess(retryChatRoomMessage);
} else {
emitter.onError(throwable);
}
});
})
.retryWhen(flowable -> flowable
.flatMap(new Function<Throwable, Publisher<?>>() {
@Override

View File

@@ -83,6 +83,7 @@ public class Constants {
public static final String ROOM_UID = "ROOM_UID";
public static final String ROOM_TYPE = "ROOM_TYPE";
public static final String ROOM_INFO = "ROOM_INFO";
public static final String IS_ROOM_MIN = "is_room_min";
public static final String IS_PARTY = "is_party";

View File

@@ -141,6 +141,140 @@ public class RoomInfo implements Parcelable,Serializable {
private long worldId; // >0:语音派对房
protected RoomInfo(Parcel in) {
uid = in.readLong();
officeUser = in.readInt();
roomId = in.readLong();
roomUid = in.readLong();
title = in.readString();
avatar = in.readString();
type = in.readInt();
roomDesc = in.readString();
backPic = in.readString();
speakTemplate = in.createStringArrayList();
valid = in.readByte() != 0;
operatorStatus = in.readInt();
hasAnimationEffect = in.readByte() != 0;
audioQuality = in.readInt();
isCloseScreen = in.readByte() != 0;
serverRedEnvelopeSwitch = in.readByte() != 0;
hasDragonGame = in.readByte() != 0;
meetingName = in.readString();
roomPwd = in.readString();
roomTag = in.readString();
tagId = in.readInt();
tagPict = in.readString();
onlineNum = in.readInt();
isRecom = in.readByte();
isRoomFans = in.readByte() != 0;
background = in.readParcelable(BackgroundBean.class.getClassLoader());
hasKTVPriv = in.readByte() != 0;
isOpenKTV = in.readByte() != 0;
isOpenGame = in.readByte() != 0;
boxSwitchVo = in.readParcelable(BoxSwitchVo.class.getClassLoader());
singingMusicName = in.readString();
limitType = in.readString();
introduction = in.readString();
roomModeType = in.readInt();
isPermitRoom = in.readInt();
isPureMode = in.readByte() != 0;
closeBox = in.readByte() != 0;
leaveMode = in.readByte() != 0;
nick = in.readString();
gender = in.readInt();
worldId = in.readLong();
showGiftValue = in.readByte() != 0;
hideFlag = in.readInt();
closeScreenFlag = in.readInt();
redEnvelopeOpen = in.readByte() != 0;
blindDateState = in.readString();
blindDateVipUid = in.readLong();
canOpenBlindDate = in.readByte() != 0;
audioSdkType = in.readString();
trtcSig = in.readString();
isReselect = in.readByte() != 0;
mgId = in.readLong();
mgName = in.readString();
mgMicNum = in.readInt();
clearScreenTime = in.readLong();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(uid);
dest.writeInt(officeUser);
dest.writeLong(roomId);
dest.writeLong(roomUid);
dest.writeString(title);
dest.writeString(avatar);
dest.writeInt(type);
dest.writeString(roomDesc);
dest.writeString(backPic);
dest.writeStringList(speakTemplate);
dest.writeByte((byte) (valid ? 1 : 0));
dest.writeInt(operatorStatus);
dest.writeByte((byte) (hasAnimationEffect ? 1 : 0));
dest.writeInt(audioQuality);
dest.writeByte((byte) (isCloseScreen ? 1 : 0));
dest.writeByte((byte) (serverRedEnvelopeSwitch ? 1 : 0));
dest.writeByte((byte) (hasDragonGame ? 1 : 0));
dest.writeString(meetingName);
dest.writeString(roomPwd);
dest.writeString(roomTag);
dest.writeInt(tagId);
dest.writeString(tagPict);
dest.writeInt(onlineNum);
dest.writeByte(isRecom);
dest.writeByte((byte) (isRoomFans ? 1 : 0));
dest.writeParcelable(background, flags);
dest.writeByte((byte) (hasKTVPriv ? 1 : 0));
dest.writeByte((byte) (isOpenKTV ? 1 : 0));
dest.writeByte((byte) (isOpenGame ? 1 : 0));
dest.writeParcelable(boxSwitchVo, flags);
dest.writeString(singingMusicName);
dest.writeString(limitType);
dest.writeString(introduction);
dest.writeInt(roomModeType);
dest.writeInt(isPermitRoom);
dest.writeByte((byte) (isPureMode ? 1 : 0));
dest.writeByte((byte) (closeBox ? 1 : 0));
dest.writeByte((byte) (leaveMode ? 1 : 0));
dest.writeString(nick);
dest.writeInt(gender);
dest.writeLong(worldId);
dest.writeByte((byte) (showGiftValue ? 1 : 0));
dest.writeInt(hideFlag);
dest.writeInt(closeScreenFlag);
dest.writeByte((byte) (redEnvelopeOpen ? 1 : 0));
dest.writeString(blindDateState);
dest.writeLong(blindDateVipUid);
dest.writeByte((byte) (canOpenBlindDate ? 1 : 0));
dest.writeString(audioSdkType);
dest.writeString(trtcSig);
dest.writeByte((byte) (isReselect ? 1 : 0));
dest.writeLong(mgId);
dest.writeString(mgName);
dest.writeInt(mgMicNum);
dest.writeLong(clearScreenTime);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<RoomInfo> CREATOR = new Creator<RoomInfo>() {
@Override
public RoomInfo createFromParcel(Parcel in) {
return new RoomInfo(in);
}
@Override
public RoomInfo[] newArray(int size) {
return new RoomInfo[size];
}
};
/**
* 获取房间类型,目前是用于统计
*/
@@ -207,99 +341,6 @@ public class RoomInfo implements Parcelable,Serializable {
public RoomInfo() {
}
protected RoomInfo(Parcel in) {
uid = in.readLong();
officeUser = in.readInt();
roomId = in.readLong();
title = in.readString();
type = in.readInt();
roomDesc = in.readString();
backPic = in.readString();
valid = in.readByte() != 0;
hasAnimationEffect = in.readByte() != 0;
operatorStatus = in.readInt();
meetingName = in.readString();
// openTime = in.readLong();
roomPwd = in.readString();
roomTag = in.readString();
tagId = in.readInt();
audioQuality = in.readInt();
tagPict = in.readString();
onlineNum = in.readInt();
limitType = in.readString();
isRecom = in.readByte();
isRoomFans = in.readByte()!=0;
avatar = in.readString();
isOpenGame = in.readByte()!=0;
isOpenKTV = in.readByte() != 0;
hasKTVPriv = in.readByte() != 0;
introduction = in.readString();
isPermitRoom = in.readInt();
showGiftValue = in.readByte() != 0;
serverRedEnvelopeSwitch = in.readByte() != 0;
nick = in.readString();
gender = in.readInt();
hideFlag = in.readInt();
closeScreenFlag = in.readInt();
speakTemplate = in.createStringArrayList();
boxSwitchVo = in.readParcelable(BoxSwitchVo.class.getClassLoader());
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(uid);
dest.writeInt(officeUser);
dest.writeLong(roomId);
dest.writeString(title);
dest.writeInt(type);
dest.writeString(roomDesc);
dest.writeString(backPic);
dest.writeByte((byte) (valid ? 1 : 0));
dest.writeByte((byte) (hasAnimationEffect ? 1 : 0));
dest.writeInt(operatorStatus);
dest.writeString(meetingName);
// dest.writeLong(openTime);
dest.writeString(roomPwd);
dest.writeString(roomTag);
dest.writeInt(tagId);
dest.writeInt(audioQuality);
dest.writeString(tagPict);
dest.writeInt(onlineNum);
dest.writeByte(isRecom);
dest.writeByte((byte) (isRoomFans ? 1 : 0));
dest.writeString(limitType);
dest.writeString(avatar);
dest.writeByte((byte) (isOpenGame ? 1 : 0));
dest.writeByte((byte) (isOpenKTV ? 1 : 0));
dest.writeByte((byte) (hasKTVPriv ? 1 : 0));
dest.writeString(introduction);
dest.writeInt(isPermitRoom);
dest.writeByte((byte) (showGiftValue ? 1 : 0));
dest.writeByte((byte) (serverRedEnvelopeSwitch ? 1 : 0));
dest.writeInt(gender);
dest.writeString(nick);
dest.writeStringList(speakTemplate);
dest.writeInt(hideFlag);
dest.writeInt(closeScreenFlag);
dest.writeParcelable(boxSwitchVo, flags);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<RoomInfo> CREATOR = new Creator<RoomInfo>() {
@Override
public RoomInfo createFromParcel(Parcel in) {
return new RoomInfo(in);
}
@Override
public RoomInfo[] newArray(int size) {
return new RoomInfo[size];
}
};
public static class BackgroundBean implements Parcelable{
/**