新增贵族礼物tab

This commit is contained in:
huangjian
2021-12-24 11:14:03 +08:00
parent 7ba49c27a4
commit c93942e246
7 changed files with 102 additions and 108 deletions

View File

@@ -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<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
private var isCloseScreen = false
private var isOpenRedPackage = false
private var isRoomMin = false
@JvmField
protected var isDatingMode = false
/**
@@ -284,6 +287,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
}
RoomEvent.ROOM_INFO_UPDATE -> {
Logger.i("房间更新事件")
addOpenDatingTips() //一定要放在updateView之前!!!
updateScreen()
updateRedPackage()
updateView()
@@ -1059,6 +1063,18 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
.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)
}
}
/**
* 底部按钮点击处理
*/

View File

@@ -166,7 +166,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
//添加变量
private boolean isKtvMode = false;
private Disposable ktvDisposable;
private boolean isDatingMode;
/**
* 排麦弹框
@@ -300,7 +300,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
}
break;
case RoomEvent.ROOM_INFO_UPDATE:
addOpenDatingTips(); //一定要放在updateView之前!!!
gameBinding.setRoomInfo(AvRoomDataManager.get().mCurrentRoomInfo);
updateQueuingMicBtn();
updatePkScoreBoard();
@@ -1536,16 +1535,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
.subscribe();
}
/**
* 开启相亲模式管理增加一条公屏提示
*/
private void addOpenDatingTips() {
if (AvRoomDataManager.get().isDatingMode() && !isDatingMode && AvRoomDataManager.get().isManager()) {
ChatRoomMessage tipMessage = ChatRoomMessageBuilder.createTipMessage(XChatConstants.DATING_TIPS_OPEN);
tipMessage.setContent(XChatConstants.DATING_TIPS_OPEN);
IMNetEaseManager.get().addMessages(tipMessage);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onFirstRechargeEvent(FirstChargeEvent event) {

View File

@@ -399,10 +399,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
updateGiftView(giftIndicator.getCurrrentType());
goldWalletInfo = PayModel.get().getCurrentWalletInfo();
//首充逻辑
//updateFirstRechargeStatus();
View descLayout = root.findViewById(R.id.desc_layout);
if (isInRoom && (userOnMic || (uid == 0))) {
@@ -856,8 +852,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
} else {
// 私聊送礼面板 不在房间内,直接在普通的列表里选出房间礼物进行显示
giftInfos = GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_NORMAL);
//加入福袋礼物到私聊礼物列表
// giftInfos.addAll(0,GiftModel.get().getGiftInfosByType(roomUid, GiftType.GIFT_TYPE_LUCKY));
}
if (ListUtils.isListEmpty(giftInfos)) return new ArrayList<>();
return giftInfos;
@@ -883,15 +877,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
}
private List<GiftInfo> getNobleGiftInfos() {
List<GiftInfo> giftInfos = loadGiftInfoList();
List<GiftInfo> 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) {

View File

@@ -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<GiftInfo> knapList;
private List<CustomAttachment> 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<GiftInfo> knapList;
private List<CustomAttachment> giftQueue;
private static class UiHandler extends Handler {
WeakReference<GiftModel> 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<ServiceResult<GiftListInfo>> refreshGiftList(String roomUid) {
return requestGiftInfos(roomUid);
return loadGiftInfoList(roomUid);
}
/**
@@ -157,14 +131,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
* @return
*/
private Single<ServiceResult<GiftListInfo>> 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<GiftInfo> getGiftInfoList(int giftType) {
if (giftListInfo != null) {
List<GiftInfo> giftInfos = giftListInfo.getGift();
List<GiftInfo> 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<GiftInfo> getGiftInfosByType(String roomUid, int giftType) {
if (allGiftListInfo != null && allGiftListInfo.getGift() != null && allGiftListInfo.getGift().size() > 0) {
List<GiftInfo> 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<GiftInfo> 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<GiftInfo> 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<ServiceResult<GiftListInfo>> 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<GiftModel> 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);
}
}
}
}

View File

@@ -78,5 +78,8 @@ public class GiftInfo implements Serializable {
*/
private String giftExplainUrl;
private int vipLevel;
private String vipIcon;
}

View File

@@ -11,7 +11,10 @@ import lombok.Data;
*/
@Data
public class GiftListInfo implements Serializable {
private List<GiftInfo> gift;
private List<GiftInfo> luckyBagGift;
private List<GiftInfo> vipGift;
private List<GiftInfo> normalGift;
private List<GiftInfo> luckyPoolGift;
private String giftVersion;
}

View File

@@ -24,4 +24,10 @@ public class GiftType {
* 礼物类型 -- 套卡
*/
public static final int CARDS = 4;
/**
* 礼物类型 -- 福袋
*/
public static final int GIFT_TYPE_VIP = 7;
}