完成涂鸦礼物功能
This commit is contained in:
@@ -194,6 +194,9 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
case GiftType.GIFT_TYPE_WEEK_STAR:
|
||||
giftInfos = allGiftListInfo.getWeekStarGift();
|
||||
break;
|
||||
case GiftType.GIFT_TYPE_DRAW_GIFT:
|
||||
giftInfos = allGiftListInfo.getDrawGift();
|
||||
break;
|
||||
}
|
||||
return giftInfos == null ? new ArrayList<>() : giftInfos;
|
||||
}
|
||||
@@ -309,10 +312,13 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
boolean isKnap,
|
||||
boolean isWholeMic,
|
||||
String chatSessionId,
|
||||
List<List<Integer>> drawFixedArray) {
|
||||
@Nullable List<List<Integer>> drawFixedArray) {
|
||||
if (ListUtils.isListEmpty(targetUids)) {
|
||||
return Single.error(new Throwable("targetUids is empty"));
|
||||
}
|
||||
if (!ListUtils.isListEmpty(drawFixedArray)) {
|
||||
giftNum = drawFixedArray.size();
|
||||
}
|
||||
if (giftNum <= 0) {
|
||||
return Single.error(new Throwable("giftNum must larger than 0"));
|
||||
}
|
||||
@@ -352,6 +358,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
}
|
||||
String targetUidsString = joinTargetUidsToString(targetUids);
|
||||
String finalRoomUid = roomUid;
|
||||
int finalGiftNum = giftNum;
|
||||
single = api.sendGift(uid, targetUidsString, roomUid,
|
||||
giftInfo.getGiftId(), giftNum, msg, sendType, source, chatSessionId)
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
@@ -360,9 +367,9 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
if (serviceResult.isSuccess()) {
|
||||
if (isKnap) {
|
||||
//应通过id去确定要需要更新的礼物背包
|
||||
EventBus.getDefault().post(new UpdateKnapEvent(giftId, giftNum * targetUids.size()));
|
||||
EventBus.getDefault().post(new UpdateKnapEvent(giftId, finalGiftNum * targetUids.size()));
|
||||
} else {
|
||||
PayModel.get().minusGold(giftInfo.getGoldPrice() * giftNum * targetUids.size());
|
||||
PayModel.get().minusGold(giftInfo.getGoldPrice() * finalGiftNum * targetUids.size());
|
||||
}
|
||||
GiftMultiReceiverInfo giftMultiReceiverInfo = serviceResult.getData();
|
||||
if (giftId != giftMultiReceiverInfo.getGiftId()) {
|
||||
@@ -561,6 +568,9 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
if (giftInfo == null) {
|
||||
giftInfo = findGiftInfoById(allGiftListInfo.getWeekStarGift(), giftId);
|
||||
}
|
||||
if (giftInfo == null) {
|
||||
giftInfo = findGiftInfoById(allGiftListInfo.getDrawGift(), giftId);
|
||||
}
|
||||
}
|
||||
return giftInfo;
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.yizhuan.xchat_android_core.gift;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
@@ -15,6 +17,7 @@ public interface IGiftModel {
|
||||
|
||||
/**
|
||||
* 加载普通礼物,不带上房间专属的礼物
|
||||
*
|
||||
* @param roomUid
|
||||
* @return
|
||||
*/
|
||||
@@ -22,6 +25,7 @@ public interface IGiftModel {
|
||||
|
||||
/**
|
||||
* 进入房间后,刷新礼物列表, 保留原来的不带有房间专属礼物的列表
|
||||
*
|
||||
* @param roomUid
|
||||
* @return
|
||||
*/
|
||||
@@ -29,30 +33,34 @@ public interface IGiftModel {
|
||||
|
||||
/**
|
||||
* 加载背包礼物
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Single<ServiceResult<List<GiftInfo>>> requestKnapGiftInfos();
|
||||
|
||||
/**
|
||||
* 从内存里取出背包礼物列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<GiftInfo> getKnapList();
|
||||
|
||||
/**
|
||||
* 从内存里取出背包礼物列表
|
||||
*
|
||||
* @param giftType 礼物类型
|
||||
* @see com.yizhuan.xchat_android_core.gift.bean.GiftType
|
||||
* @return
|
||||
* @see com.yizhuan.xchat_android_core.gift.bean.GiftType
|
||||
*/
|
||||
List<GiftInfo> getGiftInfoList(int giftType);
|
||||
|
||||
/**
|
||||
* 根据礼物类型获取礼物列表
|
||||
*
|
||||
* @param roomUid
|
||||
* @param giftType
|
||||
* @see com.yizhuan.xchat_android_core.gift.bean.GiftType
|
||||
* @return
|
||||
* @see com.yizhuan.xchat_android_core.gift.bean.GiftType
|
||||
*/
|
||||
List<GiftInfo> getGiftInfosByType(String roomUid, int giftType);
|
||||
|
||||
@@ -62,6 +70,7 @@ public interface IGiftModel {
|
||||
|
||||
/**
|
||||
* 送礼物的统一接口,(房间、私聊 和 公聊大厅)送礼物都调用这个方法
|
||||
*
|
||||
* @param giftId
|
||||
* @param giftNum
|
||||
* @param targetUids
|
||||
@@ -89,7 +98,7 @@ public interface IGiftModel {
|
||||
boolean isKnap,
|
||||
boolean isWholeMic,
|
||||
String chatSessionId,
|
||||
List<List<Integer>> drawFixedArray);
|
||||
@Nullable List<List<Integer>> drawFixedArray);
|
||||
|
||||
/**
|
||||
* 房间内发送礼物
|
||||
@@ -138,6 +147,7 @@ public interface IGiftModel {
|
||||
|
||||
/**
|
||||
* 判断是否能用贵族礼物
|
||||
*
|
||||
* @param giftInfo
|
||||
* @return
|
||||
*/
|
||||
@@ -145,6 +155,7 @@ public interface IGiftModel {
|
||||
|
||||
/**
|
||||
* 往内存的缓存中添加新的礼物数据
|
||||
*
|
||||
* @param giftInfo
|
||||
*/
|
||||
void addNewGift(GiftInfo giftInfo);
|
||||
@@ -174,10 +185,10 @@ public interface IGiftModel {
|
||||
* @return -
|
||||
*/
|
||||
Single<ServiceResult<GiftMultiReceiverInfo>> sendTeamGift(int giftId,
|
||||
String targetUid,
|
||||
int giftNum,
|
||||
String msg,
|
||||
boolean isKnap, String chatSessionId);
|
||||
String targetUid,
|
||||
int giftNum,
|
||||
String msg,
|
||||
boolean isKnap, String chatSessionId);
|
||||
|
||||
/**
|
||||
* 开通粉丝团送礼物
|
||||
@@ -187,5 +198,5 @@ public interface IGiftModel {
|
||||
* @return -
|
||||
*/
|
||||
Single<ServiceResult<GiftMultiReceiverInfo>> sendFansTeamGift(int giftId,
|
||||
String targetUid);
|
||||
String targetUid);
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ public class GiftListInfo implements Serializable {
|
||||
private List<GiftInfo> normalGift;
|
||||
private List<GiftInfo> luckyPoolGift;
|
||||
private List<GiftInfo> weekStarGift;
|
||||
private List<GiftInfo> drawGift;
|
||||
private String giftVersion;
|
||||
|
||||
}
|
||||
|
@@ -36,4 +36,6 @@ public class GiftType {
|
||||
*/
|
||||
|
||||
public static final int GIFT_TYPE_WEEK_STAR = 8;
|
||||
|
||||
public static final int GIFT_TYPE_DRAW_GIFT = 10;
|
||||
}
|
||||
|
Reference in New Issue
Block a user