This commit is contained in:
oujunhui
2020-07-21 19:32:10 +08:00
parent 91353bfe4b
commit 010b82d088
12 changed files with 82 additions and 41 deletions

View File

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

View File

@@ -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<IHomePartyView, HomeP
private boolean isGameMode = false;
private Disposable ktvDisposable;
private boolean isCloseScreen;
private boolean isRedPackage;
private boolean isRoomPureMode;
/**
* 是否开启礼物值显示
@@ -407,6 +409,7 @@ public class HomePartyRoomFragment extends BaseMvpFragment<IHomePartyView, HomeP
//audioQulity = AvRoomDataManager.get().mCurrentRoomInfo.getAudioQuality();
gameBinding.setRoomInfo(AvRoomDataManager.get().mCurrentRoomInfo);
isCloseScreen = AvRoomDataManager.get().isCloseScreen();
isRedPackage = AvRoomDataManager.get().serverRedEnvelopeSwitch;
isRoomPureMode = AvRoomDataManager.get().isOpenPureMode();
showGiftValue = AvRoomDataManager.get().isShowGiftValue();
openOrCloseGiftValue(true);
@@ -2349,6 +2352,11 @@ public class HomePartyRoomFragment extends BaseMvpFragment<IHomePartyView, HomeP
public void onSuperAdmin() {
RoomSAdminManagerActivity.start(mContext);
}
@Override
public void onSwitchRedPackage() {
getMvpPresenter().updateRedPackage();
}
});
dialog.show();
}

View File

@@ -38,6 +38,7 @@ import com.yizhuan.xchat_android_core.miniworld.model.MiniWorldModel;
import com.yizhuan.xchat_android_core.pay.PayModel;
import com.yizhuan.xchat_android_core.pay.bean.WalletInfo;
import com.yizhuan.xchat_android_core.praise.PraiseModel;
import com.yizhuan.xchat_android_core.redpackage.RedPackageModel;
import com.yizhuan.xchat_android_core.room.bean.DragonBarInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.room.dragonball.DragonBallModel;
@@ -679,6 +680,29 @@ public class HomePartyPresenter extends BaseMvpPresenter<IHomePartyView> {
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<String, Object> reason = new HashMap<>(2);
reason.put("reason", "kick");

View File

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

View File

@@ -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<V extends IMvpBaseView, P extends Abstract
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 (context instanceof AddUserInfoActivity || context instanceof LoginActivity || UserUtils.getUserInfo() == null)
return;
@@ -973,8 +971,10 @@ public abstract class BaseMvpActivity<V extends IMvpBaseView, P extends Abstract
if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) {//红包所在房间 是在房间
RedPackageOpenDialog.Companion.newInstance(notifyInfo).show(this);
} else {
LogUtil.e("Red_Base:"+AvRoomDataManager.get().mIsNeedOpenRedPackage);
if (roomInfo != null && roomInfo.getUid() != notifyInfo.getRoomUid() && AvRoomDataManager.get().mIsNeedOpenRedPackage && context instanceof AVRoomActivity){
LogUtil.e("Red_Base:"+AvRoomDataManager.get().serverRedEnvelopeSwitch);
if (roomInfo != null && roomInfo.getUid() != notifyInfo.getRoomUid() && AvRoomDataManager.get().serverRedEnvelopeSwitch && context instanceof AVRoomActivity){
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
}else if (roomInfo == null){
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
}
}

View File

@@ -250,7 +250,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_MSG_SUB_QUEUING_MIC_MODE_OPEN;
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_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_MONSTER_HUNTING;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ADD_BLACK;
@@ -259,6 +258,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;
@@ -1211,7 +1211,6 @@ public final class IMNetEaseManager {
case CustomAttachment.CUSTOM_MSG_RED_PACKAGE:
switch (second) {
case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_GIFT:
case CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND:
noticeRoomEvent(msg, RoomEvent.RECEIVE_RED_PACKAGE);
break;
@@ -1688,6 +1687,10 @@ public final class IMNetEaseManager {
noticeReceiverMessage(msg);
}
public void addRedPackageSwitch(ChatRoomMessage msg){
noticeReceiverMessage(msg);
}
public Observable<ChatRoomMessage> 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<ChatRoomMessage> 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);
}
/**
* <p>下麦</p>
* 云信聊天室队列服务:加入或者更新队列元素,支持当用户掉线或退出聊天室后,是否删除这个元素

View File

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

View File

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

View File

@@ -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模式
*

View File

@@ -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<String>{
return api.getRedPackageSwitch(roomUid)
.io2main()
.handleStringData()
}
fun setRedPackageSwitch(roomUid: Long):Single<String> {
fun setRedPackageSwitch(roomUid: Long):Single<Boolean> {
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<ServiceResult<List<RedEnvelopeVO>>>
@GET("/red-envelope/{roomUid}")
fun getRedPackageSwitch(@Path("roomUid") uid: Long): Single<ServiceResult<String>>
/**
* 房间全服红包开关
*/
@POST("/red-envelope/switch/{roomUid}")
fun setRedPackageSwitch(@Path("roomUid") uid: Long): Single<ServiceResult<String>>
fun setRedPackageSwitch(@Path("roomUid") uid: Long): Single<ServiceResult<Boolean>>
}

View File

@@ -57,6 +57,7 @@ public class RoomInfo implements Parcelable,Serializable {
private int audioQuality;
// true为关闭 false为开启
private boolean isCloseScreen;
// 是否有桌球游戏
public boolean hasDragonGame;

View File

@@ -33,6 +33,7 @@ import io.reactivex.Single;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import retrofit2.http.Path;
/**
* <p> 轰趴房model层数据获取 </p>
@@ -202,7 +203,6 @@ public class HomePartyModel extends RoomBaseModel implements IHomePartyModel {
}
/**
* 轰趴房间服务器相关接口
*/