From 010b82d08834c3edf339077679e49e8ac410d93f Mon Sep 17 00:00:00 2001 From: oujunhui <313127320@qq.com> Date: Tue, 21 Jul 2020 19:32:10 +0800 Subject: [PATCH] bugfix --- .../avroom/dialog/RoomOperationDialog.java | 19 +++++++-------- .../fragment/HomePartyRoomFragment.java | 8 +++++++ .../avroom/presenter/HomePartyPresenter.java | 24 +++++++++++++++++++ .../com/yizhuan/erban/base/BaseActivity.java | 2 -- .../yizhuan/erban/base/BaseMvpActivity.java | 8 +++---- .../manager/IMNetEaseManager.java | 23 ++++++++++++++++-- .../im/custom/bean/CustomAttachParser.java | 6 ++--- .../im/custom/bean/CustomAttachment.java | 3 +-- .../manager/AvRoomDataManager.java | 10 ++++---- .../redpackage/RedPackageModel.kt | 17 +++++-------- .../room/bean/RoomInfo.java | 1 + .../room/model/HomePartyModel.java | 2 +- 12 files changed, 82 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/com/yizhuan/erban/avroom/dialog/RoomOperationDialog.java b/app/src/main/java/com/yizhuan/erban/avroom/dialog/RoomOperationDialog.java index cfc6ea18c..179bdc004 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/dialog/RoomOperationDialog.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/dialog/RoomOperationDialog.java @@ -106,27 +106,22 @@ public class RoomOperationDialog extends BottomSheetDialog { if (!AvRoomDataManager.get().isManager()) { return; } - RedPackageModel.INSTANCE.getRedPackageSwitch(AvRoomDataManager.get().getRoomUid()).subscribe(s -> { - boolean isShowRedPackage = Boolean.parseBoolean(s); - LogUtil.e("Red_RoomOpera:"+isShowRedPackage); - AvRoomDataManager.get().mIsNeedOpenRedPackage = isShowRedPackage; - String text = isShowRedPackage ? + + boolean getIsShowRedPackage = AvRoomDataManager.get().serverRedEnvelopeSwitch; + String text = getIsShowRedPackage ? context.getResources().getString(R.string.close_redpackage_notice) : context.getResources().getString(R.string.open_redpackage_notice); - int icon = isShowRedPackage ? + int icon = getIsShowRedPackage ? R.drawable.ic_room_open_redpackage : R.drawable.ic_room_close_redpackage; optAdapter.addData(new OptAction(icon, text, () -> { if (onActionListener != null) { - RedPackageModel.INSTANCE.setRedPackageSwitch(AvRoomDataManager.get().getRoomUid()).subscribe(s1 -> { - AvRoomDataManager.get().mIsNeedOpenRedPackage = Boolean.parseBoolean(s); - LogUtil.e("Red_RoomOpera:"+AvRoomDataManager.get().mIsNeedOpenRedPackage); - }); + onActionListener.onSwitchRedPackage(); } })); - }); + } private void addGameAction(OptAdapter optAdapter) { @@ -447,6 +442,8 @@ public class RoomOperationDialog extends BottomSheetDialog { void onSuperAdmin(); + void onSwitchRedPackage(); + } public void setOnActionListener(OnActionListener onActionListener) { diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java index 9152827d1..87003edc3 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java @@ -142,6 +142,7 @@ import com.yizhuan.xchat_android_core.radish.task.TaskModel; import com.yizhuan.xchat_android_core.radish.task.bean.CheckNewUserTaskInfo; import com.yizhuan.xchat_android_core.radish.task.bean.PrizeType; import com.yizhuan.xchat_android_core.redPacket.bean.ActionDialogInfo; +import com.yizhuan.xchat_android_core.redpackage.RedPackageModel; import com.yizhuan.xchat_android_core.room.activitytimer.ActivityTimerEvent; import com.yizhuan.xchat_android_core.room.activitytimer.TimerBean; import com.yizhuan.xchat_android_core.room.bean.RoomInfo; @@ -255,6 +256,7 @@ public class HomePartyRoomFragment extends BaseMvpFragment { IMNetEaseManager.get().addCloseScreenMessages(screenMsg); } + public void updateRedPackage(){ + RedPackageModel.INSTANCE.setRedPackageSwitch(AvRoomDataManager.get().getRoomUid()).subscribe(setIsNeedOpenRedPackage -> { + AvRoomDataManager.get().serverRedEnvelopeSwitch = setIsNeedOpenRedPackage; + + RoomInfoAttachment attachment = new RoomInfoAttachment(CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO, + CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_REDPACKAGE); + ChatRoomMessage screenMsg = ChatRoomMessageBuilder.createChatRoomCustomMessage( + String.valueOf(AvRoomDataManager.get().getRoomId()), + attachment + ); + IMNetEaseManager.get().addRedPackageSwitch(screenMsg); + }); + +// IMNetEaseManager.get().updateGiftEffect(AvRoomDataManager.get().getRoomUid()) +// .subscribe((chatRoomMessage, throwable) -> { +// if (!AvRoomDataManager.get().haveSelfChange) { +// IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent() +// .setEvent(RoomEvent.RECEIVE_MSG) +// .setChatRoomMessage(chatRoomMessage)); +// } +// }); + } + public void kickAi(AiPlayEndEvent aiPlayEndEvent) { final Map reason = new HashMap<>(2); reason.put("reason", "kick"); diff --git a/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java b/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java index dd165401e..211f629c1 100644 --- a/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java +++ b/app/src/main/java/com/yizhuan/erban/base/BaseActivity.java @@ -101,7 +101,6 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT; /** @@ -982,7 +981,6 @@ public abstract class BaseActivity extends RxAppCompatActivity break; case CUSTOM_MSG_RED_PACKAGE: switch (baseProtocol.getSecond()) { - case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT: case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND: if (this instanceof AddUserInfoActivity || this instanceof LoginActivity || UserUtils.getUserInfo() == null) return; diff --git a/app/src/main/java/com/yizhuan/erban/base/BaseMvpActivity.java b/app/src/main/java/com/yizhuan/erban/base/BaseMvpActivity.java index 50c336af3..a0f7ce4a8 100644 --- a/app/src/main/java/com/yizhuan/erban/base/BaseMvpActivity.java +++ b/app/src/main/java/com/yizhuan/erban/base/BaseMvpActivity.java @@ -94,7 +94,6 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT; /** @@ -964,7 +963,6 @@ public abstract class BaseMvpActivity getChatRoomMsgFlowable() { return getChatRoomMsgPublisher() @@ -2277,6 +2280,8 @@ public final class IMNetEaseManager { return sendChatRoomMessage(message, false); } + + /** * 关闭房间礼物特效 * @@ -2291,6 +2296,20 @@ public final class IMNetEaseManager { return sendChatRoomMessage(message, false); } + /** + * 关闭房间礼物特效 + * + * @param roomId 聊天室 id + */ + public Single updateRedPackageSwitch(final long roomId) { + RoomInfoAttachment queueMsgAttachment = new RoomInfoAttachment(CUSTOM_MSG_UPDATE_ROOM_INFO, + CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_REDPACKAGE); + queueMsgAttachment.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo; + ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( + String.valueOf(roomId), queueMsgAttachment); + return sendChatRoomMessage(message, false); + } + /** *

下麦

* 云信聊天室队列服务:加入或者更新队列元素,支持当用户掉线或退出聊天室后,是否删除这个元素 diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java index 7b4f31777..8c83c03db 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java @@ -84,9 +84,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_SUB_PUBLIC_CHAT_HALL_FULL_SCREEN; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_GIFT; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT; 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_GIFT; 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_TYPE_RECEIVE_LUCKY_MONEY; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ADD_BLACK; @@ -96,6 +94,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_SUB_TYPE_SEND_SINGLE_MAGIC; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO_AUDIO; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_REDPACKAGE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_SCREEN; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO_GIFT; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_UPDATE_ROOM_INFO_NOTICE; @@ -213,6 +212,7 @@ public class CustomAttachParser implements MsgAttachmentParser { case CUSTOM_MSG_UPDATE_ROOM_INFO_GIFT: case CUSTOM_MSG_UPDATE_ROOM_INFO_AUDIO: case CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_SCREEN: + case CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_REDPACKAGE: attachment = new RoomInfoAttachment(CUSTOM_MSG_UPDATE_ROOM_INFO, second); break; @@ -413,9 +413,7 @@ public class CustomAttachParser implements MsgAttachmentParser { case CUSTOM_MSG_RED_PACKAGE: switch (second) { - case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_GIFT: case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND: - case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT: case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND: attachment = new RedPackageAttachment(second); break; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java index 57fbf40d0..88b18b052 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java @@ -117,6 +117,7 @@ public class CustomAttachment implements MsgAttachment { public static final int CUSTOM_MSG_UPDATE_ROOM_INFO_AUDIO=202; public static final int CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_SCREEN=203; public static final int CUSTOM_MSG_UPDATE_ROOM_INFO_NOTICE = 204; // 通用公屏提示文案,使用于各种模式的开和关 + public static final int CUSTOM_MSG_UPDATE_ROOM_INFO_CLOSE_REDPACKAGE=205; // 群红包 public static final int CUSTOM_MSG_HEADER_TYPE_LUCKY_MONEY = 21; @@ -344,9 +345,7 @@ public class CustomAttachment implements MsgAttachment { //红包消息 public static final int CUSTOM_MSG_RED_PACKAGE = 60; - public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_GIFT = 601; public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND = 602; - public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_GIFT = 603; public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND = 604; public static final int CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG = 605; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java b/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java index fc7add4b8..cc276ead0 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java @@ -61,6 +61,10 @@ public final class AvRoomDataManager { public EnterChatRoomResultData mEnterChatRoomResultData; + /** + * 是否需要打开全服红包 + */ + public boolean serverRedEnvelopeSwitch; /** * 房间创建者 */ @@ -109,10 +113,7 @@ public final class AvRoomDataManager { * 是否需要打开礼物特效 */ public boolean mIsNeedGiftEffect = true; - /** - * 是否需要打开全服红包 - */ - public boolean mIsNeedOpenRedPackage = true; + /** * 自己是否操作过礼物特效 */ @@ -768,6 +769,7 @@ public final class AvRoomDataManager { return roomInfo.isCloseScreen(); } + /** * 是否为ktv模式 * diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageModel.kt b/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageModel.kt index e13eba02c..bbaba5f67 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageModel.kt +++ b/core/src/main/java/com/yizhuan/xchat_android_core/redpackage/RedPackageModel.kt @@ -42,16 +42,10 @@ object RedPackageModel { .map { RedPackageNotifyInfo(it.id, it.type, it.message, it.userVO?.avatar?:"", it.userVO?.nick?:"", it.roomUId, "") } } - fun getRedPackageSwitch(roomUid: Long):Single{ - return api.getRedPackageSwitch(roomUid) - .io2main() - .handleStringData() - } - - fun setRedPackageSwitch(roomUid: Long):Single { + fun setRedPackageSwitch(roomUid: Long):Single { return api.setRedPackageSwitch(roomUid) .io2main() - .handleStringData() + .handleBeanData() } private interface Api { @@ -88,11 +82,12 @@ object RedPackageModel { @GET("/room/red-envelop") fun getRedPackage(@Query("uid") uid: Long): Single>> - @GET("/red-envelope/{roomUid}") - fun getRedPackageSwitch(@Path("roomUid") uid: Long): Single> + /** + * 房间全服红包开关 + */ @POST("/red-envelope/switch/{roomUid}") - fun setRedPackageSwitch(@Path("roomUid") uid: Long): Single> + fun setRedPackageSwitch(@Path("roomUid") uid: Long): Single> } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java index 07310ae03..dbbe45b0d 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/bean/RoomInfo.java @@ -57,6 +57,7 @@ public class RoomInfo implements Parcelable,Serializable { private int audioQuality; // true为关闭 false为开启 private boolean isCloseScreen; + // 是否有桌球游戏 public boolean hasDragonGame; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/HomePartyModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/HomePartyModel.java index 001197195..fe55d8cb7 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/HomePartyModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/HomePartyModel.java @@ -33,6 +33,7 @@ import io.reactivex.Single; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST; +import retrofit2.http.Path; /** *

轰趴房model层:数据获取

@@ -202,7 +203,6 @@ public class HomePartyModel extends RoomBaseModel implements IHomePartyModel { } - /** * 轰趴房间服务器相关接口 */