diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt b/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt index 4f96c1e67..5876d03e0 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt @@ -61,6 +61,7 @@ import com.yizhuan.erban.ui.widget.rollviewpager.Util import com.yizhuan.erban.ui.widget.rollviewpager.hintview.ColorPointHintView import com.yizhuan.erban.utils.KeyBoardUtils import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity +import com.yizhuan.xchat_android_constants.XChatConstants import com.yizhuan.xchat_android_core.Constants import com.yizhuan.xchat_android_core.UriProvider import com.yizhuan.xchat_android_core.auth.AuthModel @@ -133,6 +134,8 @@ open class BaseRoomFragment?> : private var isCloseScreen = false private var isOpenRedPackage = false private var isRoomMin = false + @JvmField + protected var isDatingMode = false /** @@ -284,6 +287,7 @@ open class BaseRoomFragment?> : } RoomEvent.ROOM_INFO_UPDATE -> { Logger.i("房间更新事件") + addOpenDatingTips() //一定要放在updateView之前!!! updateScreen() updateRedPackage() updateView() @@ -1059,6 +1063,18 @@ open class BaseRoomFragment?> : .onEvent(StatisticsProtocol.Event.EVENT_MP_ROOM_GIFT_CLICK, "礼物面板按钮") } + /** + * 开启相亲模式管理增加一条公屏提示 + */ + private fun addOpenDatingTips() { + if (AvRoomDataManager.get().isDatingMode && !isDatingMode && AvRoomDataManager.get().isManager) { + val tipMessage = + ChatRoomMessageBuilder.createTipMessage(XChatConstants.DATING_TIPS_OPEN) + tipMessage.content = XChatConstants.DATING_TIPS_OPEN + IMNetEaseManager.get().addMessages(tipMessage) + } + } + /** * 底部按钮点击处理 */ 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 67a5c1734..21f1c9028 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 @@ -166,7 +166,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment(); return giftInfos; @@ -883,15 +877,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene } private List getNobleGiftInfos() { - List giftInfos = loadGiftInfoList(); - List infos = new ArrayList<>(); - for (int i = 0; i < giftInfos.size(); i++) { - GiftInfo giftInfo = giftInfos.get(i); - if (giftInfo.isNobleGift() || giftInfo.getLevel() > 0) { - infos.add(giftInfo); - } - } - return infos; + return GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_VIP); } private void initEasyPop(boolean isBag) { diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/gift/GiftModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/gift/GiftModel.java index 5d7369054..3151ba446 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/gift/GiftModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/gift/GiftModel.java @@ -72,6 +72,8 @@ 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_LUCKY_GIFT; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_MULTI_LUCK_GIFT; +import androidx.annotation.Nullable; + /** * Created by yudi @@ -79,19 +81,20 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS */ public class GiftModel extends BaseModel implements IGiftModel { + private volatile static IGiftModel model; private Api api; private UiHandler handler; + private GiftListInfo allGiftListInfo; + private List knapList; + private List giftQueue; private GiftModel() { api = RxNet.create(Api.class); -// allGiftListInfo = DemoCache.readGiftList(); giftQueue = new ArrayList<>(); handler = new UiHandler(this); loadGiftInfoList(null).subscribe(); } - private volatile static IGiftModel model; - public static IGiftModel get() { if (model == null) { synchronized (GiftModel.class) { @@ -103,35 +106,6 @@ public class GiftModel extends BaseModel implements IGiftModel { return model; } - private GiftListInfo allGiftListInfo; - private GiftListInfo giftListInfo; - private List knapList; - private List giftQueue; - - private static class UiHandler extends Handler { - WeakReference mReference; - - UiHandler(GiftModel giftModel) { - mReference = new WeakReference<>(giftModel); - } - - @Override - public void handleMessage(Message msg) { - GiftModel giftModel = mReference.get(); - if (giftModel == null) return; - super.handleMessage(msg); - if (giftModel.giftQueue.size() > 0) { - CustomAttachment attachment = giftModel.giftQueue.remove(0); - if (attachment != null) - giftModel.parseChatRoomAttachment(attachment); - } - - if (giftModel.giftQueue.size() > 0) { - sendEmptyMessageDelayed(0, 150); - } - } - } - private void addGiftMessage(CustomAttachment attachment) { giftQueue.add(attachment); if (giftQueue.size() == 1) { @@ -147,7 +121,7 @@ public class GiftModel extends BaseModel implements IGiftModel { */ @Override public Single> refreshGiftList(String roomUid) { - return requestGiftInfos(roomUid); + return loadGiftInfoList(roomUid); } /** @@ -157,14 +131,7 @@ public class GiftModel extends BaseModel implements IGiftModel { * @return */ private Single> requestGiftInfos(String roomUid) { - return api.requestGiftInfos(roomUid) - .compose(new Transformer<>()) - .doOnSuccess(response -> { - if (response.isSuccess()) { - allGiftListInfo = response.getData(); -// DemoCache.saveGiftList(allGiftListInfo); - } - }); + return loadGiftInfoList(roomUid); } /** @@ -179,7 +146,6 @@ public class GiftModel extends BaseModel implements IGiftModel { .compose(new Transformer<>()) .doOnSuccess(response -> { if (response.isSuccess()) { - giftListInfo = response.getData(); allGiftListInfo = response.getData(); } }); @@ -211,36 +177,28 @@ public class GiftModel extends BaseModel implements IGiftModel { @Override public List getGiftInfoList(int giftType) { - if (giftListInfo != null) { - List giftInfos = giftListInfo.getGift(); - List result = new ArrayList<>(); - for (GiftInfo giftInfo : giftInfos) { - if (giftInfo.getGiftType() == giftType) { - result.add(giftInfo); - } - } - return result; - } else { - loadGiftInfoList(null).subscribe(); - } - return new ArrayList<>(); + return getGiftInfosByType(null, giftType); } @Override public List getGiftInfosByType(String roomUid, int giftType) { - if (allGiftListInfo != null && allGiftListInfo.getGift() != null && allGiftListInfo.getGift().size() > 0) { - List giftInfos = new ArrayList<>(); - for (int i = 0; i < allGiftListInfo.getGift().size(); i++) { - GiftInfo giftInfo = allGiftListInfo.getGift().get(i); - if (giftInfo.getGiftType() == giftType) { - giftInfos.add(giftInfo); - } - } - return giftInfos; - } else { + if (allGiftListInfo == null) { requestGiftInfos(roomUid).subscribe(); + return new ArrayList<>(); } - return new ArrayList<>(); + List giftInfos = null; + switch (giftType) { + case GiftType.GIFT_TYPE_NORMAL: + giftInfos = allGiftListInfo.getNormalGift(); + break; + case GiftType.GIFT_TYPE_LUCKY: + giftInfos = allGiftListInfo.getLuckyBagGift(); + break; + case GiftType.GIFT_TYPE_VIP: + giftInfos = allGiftListInfo.getVipGift(); + break; + } + return giftInfos == null ? new ArrayList<>() : giftInfos; } @Override @@ -557,14 +515,7 @@ public class GiftModel extends BaseModel implements IGiftModel { @Override public void addNewGift(GiftInfo giftInfo) { - if (giftInfo == null || allGiftListInfo == null || ListUtils.isListEmpty(allGiftListInfo.getGift())) - return; - if (findGiftInfoById(giftInfo.getGiftId()) == null) { - allGiftListInfo.getGift().add(1, giftInfo); - if (AvRoomDataManager.get().mCurrentRoomInfo != null) { - requestGiftInfos(String.valueOf(AvRoomDataManager.get().mCurrentRoomInfo.getUid())).subscribe(); - } - } + //兼容旧版写的,已经不需要了 } /** @@ -575,12 +526,28 @@ public class GiftModel extends BaseModel implements IGiftModel { */ @Override public GiftInfo findGiftInfoById(int giftId) { + GiftInfo giftInfo = null; if (allGiftListInfo != null) { - for (int i = 0; i < allGiftListInfo.getGift().size(); i++) { - GiftInfo giftInfo = allGiftListInfo.getGift().get(i); - if (giftInfo.getGiftId() == giftId) { - return giftInfo; - } + giftInfo = findGiftInfoById(allGiftListInfo.getNormalGift(), giftId); + if (giftInfo == null) { + giftInfo = findGiftInfoById(allGiftListInfo.getVipGift(), giftId); + } + if (giftInfo == null) { + giftInfo = findGiftInfoById(allGiftListInfo.getLuckyBagGift(), giftId); + } + if (giftInfo == null) { + giftInfo = findGiftInfoById(allGiftListInfo.getLuckyPoolGift(), giftId); + } + } + return giftInfo; + } + + @Nullable + private GiftInfo findGiftInfoById(List giftInfoList, int giftId) { + if (ListUtils.isListEmpty(giftInfoList)) return null; + for (GiftInfo giftInfo : giftInfoList) { + if (giftInfo.getGiftId() == giftId) { + return giftInfo; } } return null; @@ -613,7 +580,7 @@ public class GiftModel extends BaseModel implements IGiftModel { * * @return - */ - @GET("/gift/listV3") + @GET("/gift/listV4") Single> requestGiftInfos(@Query("roomUid") String roomUid); /** @@ -648,4 +615,28 @@ public class GiftModel extends BaseModel implements IGiftModel { @Field("chatSessionId") String chatSessionId); } + + private static class UiHandler extends Handler { + WeakReference mReference; + + UiHandler(GiftModel giftModel) { + mReference = new WeakReference<>(giftModel); + } + + @Override + public void handleMessage(Message msg) { + GiftModel giftModel = mReference.get(); + if (giftModel == null) return; + super.handleMessage(msg); + if (giftModel.giftQueue.size() > 0) { + CustomAttachment attachment = giftModel.giftQueue.remove(0); + if (attachment != null) + giftModel.parseChatRoomAttachment(attachment); + } + + if (giftModel.giftQueue.size() > 0) { + sendEmptyMessageDelayed(0, 150); + } + } + } } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftInfo.java index 5849b5958..b85f7f2c9 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftInfo.java @@ -78,5 +78,8 @@ public class GiftInfo implements Serializable { */ private String giftExplainUrl; + private int vipLevel; + private String vipIcon; + } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftListInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftListInfo.java index 58e56c924..17b2bd4fb 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftListInfo.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftListInfo.java @@ -11,7 +11,10 @@ import lombok.Data; */ @Data public class GiftListInfo implements Serializable { - private List gift; + private List luckyBagGift; + private List vipGift; + private List normalGift; + private List luckyPoolGift; private String giftVersion; } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftType.java b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftType.java index e6aec27a1..58fede41e 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftType.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/gift/bean/GiftType.java @@ -24,4 +24,10 @@ public class GiftType { * 礼物类型 -- 套卡 */ public static final int CARDS = 4; + + /** + * 礼物类型 -- 福袋 + */ + + public static final int GIFT_TYPE_VIP = 7; }