涂鸦礼物初版实现

This commit is contained in:
huangjian
2022-08-18 10:10:59 +08:00
parent d2f6e5c8ff
commit cd79f0ec3a
27 changed files with 1190 additions and 699 deletions

View File

@@ -56,6 +56,7 @@ import org.greenrobot.eventbus.EventBus;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import io.reactivex.Single;
@@ -293,6 +294,11 @@ public class GiftModel extends BaseModel implements IGiftModel {
}
}
@Override
public Single<ServiceResult<GiftMultiReceiverInfo>> sendGift(int giftId, int giftNum, List<Long> targetUids, int sendType, int source, String msg, boolean isKnap, boolean isWholeMic, String chatSessionId) {
return sendGift(giftId, giftNum, targetUids, sendType, source, msg, isKnap, isWholeMic, chatSessionId, null);
}
@Override
public Single<ServiceResult<GiftMultiReceiverInfo>> sendGift(int giftId,
int giftNum,
@@ -301,7 +307,9 @@ public class GiftModel extends BaseModel implements IGiftModel {
int source,
String msg,
boolean isKnap,
boolean isWholeMic, String chatSessionId) {
boolean isWholeMic,
String chatSessionId,
List<HashMap<String, String>> drawFixedArray) {
if (ListUtils.isListEmpty(targetUids)) {
return Single.error(new Throwable("targetUids is empty"));
}
@@ -345,7 +353,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
String targetUidsString = joinTargetUidsToString(targetUids);
String finalRoomUid = roomUid;
single = api.sendGift(uid, targetUidsString, roomUid,
giftInfo.getGiftId(), giftNum, msg, sendType, source, chatSessionId)
giftInfo.getGiftId(), giftNum, msg, sendType, source, chatSessionId)
.compose(RxHelper.handleSchedulers())
.flatMap((Function<ServiceResult<GiftMultiReceiverInfo>,
SingleSource<ServiceResult<GiftMultiReceiverInfo>>>) serviceResult -> {
@@ -357,6 +365,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
PayModel.get().minusGold(giftInfo.getGoldPrice() * giftNum * targetUids.size());
}
GiftMultiReceiverInfo giftMultiReceiverInfo = serviceResult.getData();
giftMultiReceiverInfo.setDrawFixedArray(drawFixedArray);
if (giftId != giftMultiReceiverInfo.getGiftId()) {
return Single.error(RxHelper.createThrowable(serviceResult));
}
@@ -396,10 +405,9 @@ public class GiftModel extends BaseModel implements IGiftModel {
if (serviceResult.getCode() == BalanceNotEnoughExeption.code) {
IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent().setEvent(RoomEvent.RECHARGE));
return Single.error(new BalanceNotEnoughExeption(serviceResult.getMessage()));
}
else if (serviceResult.getCode() == VipLevelNotEnoughException.code) {
} else if (serviceResult.getCode() == VipLevelNotEnoughException.code) {
return Single.error(new VipLevelNotEnoughException(serviceResult.getMessage()));
}else if (RadishNotEnoughException.code == serviceResult.getCode()) {
} else if (RadishNotEnoughException.code == serviceResult.getCode()) {
//萝卜不足
IMNetEaseManager.get().getChatRoomEventObservable().onNext(
new RoomEvent().setEvent(RoomEvent.RADISH_NOT_ENOUGH));
@@ -445,12 +453,25 @@ public class GiftModel extends BaseModel implements IGiftModel {
* @return
*/
@Override
public Single<ServiceResult<GiftMultiReceiverInfo>> sendRoomGift(int giftId, List<Long> targetUids,
final int giftNum, String msg, boolean isKnap,
boolean isWholeMic) {
public Single<ServiceResult<GiftMultiReceiverInfo>> sendRoomGift(int giftId,
List<Long> targetUids,
final int giftNum,
String msg,
boolean isKnap,
boolean isWholeMic,
List<HashMap<String, String>> drawFixedArray) {
Log.e("GiftDialog", "sendRoomGift() called with: giftId = [" + giftId + "], targetUids = [" + targetUids + "], giftNum = [" + giftNum + "], msg = [" + msg + "], isKnap = [" + isKnap + "], isWholeMic = [" + isWholeMic + "]");
return sendGift(giftId, giftNum, targetUids, GiftSendType.TYPE_MIC,
isKnap ? GiftSource.BACKPACK : GiftSource.COMMON, msg, isKnap, isWholeMic, null);
return sendGift(
giftId,
giftNum,
targetUids,
GiftSendType.TYPE_MIC,
isKnap ? GiftSource.BACKPACK : GiftSource.COMMON,
msg,
isKnap,
isWholeMic,
null,
drawFixedArray);
}
/**
@@ -577,14 +598,14 @@ public class GiftModel extends BaseModel implements IGiftModel {
@Override
public Single<ServiceResult<GiftMultiReceiverInfo>> sendFansTeamGift(int giftId, String targetUid) {
return api.sendJoinFansGift(AuthModel.get().getCurrentUid(),
targetUid,
String.valueOf(AvRoomDataManager.get().getRoomUid()),
giftId,
1,
"",
GiftSendType.TYPE_ANCHOR,
GiftSource.COMMON,
null)
targetUid,
String.valueOf(AvRoomDataManager.get().getRoomUid()),
giftId,
1,
"",
GiftSendType.TYPE_ANCHOR,
GiftSource.COMMON,
null)
.compose(RxHelper.handleSchAndExce());
}

View File

@@ -6,6 +6,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftListInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo;
import java.util.HashMap;
import java.util.List;
import io.reactivex.Single;
@@ -79,6 +80,17 @@ public interface IGiftModel {
boolean isKnap,
boolean isWholeMic, String chatSessionId);
Single<ServiceResult<GiftMultiReceiverInfo>> sendGift(int giftId,
int giftNum,
List<Long> targetUids,
int sendType,
int source,
String msg,
boolean isKnap,
boolean isWholeMic,
String chatSessionId,
List<HashMap<String, String>> drawFixedArray);
/**
* 房间内发送礼物
*
@@ -93,7 +105,8 @@ public interface IGiftModel {
int giftNum,
String msg,
boolean isKnap,
boolean isWholeMic);
boolean isWholeMic,
List<HashMap<String, String>> drawFixedArray);
/**
* 在单聊界面送礼物

View File

@@ -90,4 +90,6 @@ public class GiftInfo implements Serializable {
private SimpleUserInfo firstCharmRankUser;
private boolean drawGift;
}

View File

@@ -3,6 +3,7 @@ package com.yizhuan.xchat_android_core.gift.bean;
import com.yizhuan.xchat_android_core.room.giftvalue.bean.IndexGiftValue;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import lombok.Data;
@@ -26,4 +27,5 @@ public class GiftMultiReceiverInfo implements Serializable {
private List<LuckyBagGifts> luckyBagGifts;
private List<Long> targetUids;
private LuckyGiftList luckyGiftList;
private List<HashMap<String, String>> drawFixedArray;
}

View File

@@ -29,5 +29,6 @@ public class GiftReceiveInfo implements Serializable {
//礼物值
private List<IndexGiftValue> giftValueVos;
private long currentTime;
private List<HashMap<String, String>> drawFixedArray;
}

View File

@@ -105,6 +105,7 @@ public class GiftToolbox {
giftReceiveInfo.setDisplayGift(giftMultiReceiverInfo.getDisplayGift());
giftReceiveInfo.setGiftValueVos(giftMultiReceiverInfo.getGiftValueVos());
giftReceiveInfo.setCurrentTime(giftMultiReceiverInfo.getCurrentTime());
giftReceiveInfo.setDrawFixedArray(giftMultiReceiverInfo.getDrawFixedArray());
return giftReceiveInfo;
}

View File

@@ -5,12 +5,14 @@ import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
import com.yizhuan.xchat_android_core.room.giftvalue.bean.IndexGiftValue;
import java.util.HashMap;
import java.util.List;
/**
@@ -22,6 +24,10 @@ public class GiftAttachment extends CustomAttachment {
private GiftReceiveInfo giftReceiveInfo;
private String uid;
public GiftAttachment(int first, int second) {
super(first, second);
}
public String getUid() {
return uid;
}
@@ -30,11 +36,6 @@ public class GiftAttachment extends CustomAttachment {
this.uid = uid;
}
public GiftAttachment(int first, int second) {
super(first, second);
}
public GiftReceiveInfo getGiftReceiveInfo() {
return giftReceiveInfo;
}
@@ -78,6 +79,10 @@ public class GiftAttachment extends CustomAttachment {
giftReceiveInfo.setGiftValueVos(giftValueVos);
}
}
if (data.containsKey("drawFixedArray")) {
giftReceiveInfo.setDrawFixedArray(data.getObject("drawFixedArray", new TypeReference<List<HashMap<String, String>>>() {
}.getType()));
}
giftReceiveInfo.setCurrentTime(data.getLong("currentTime"));
}
@@ -98,6 +103,9 @@ public class GiftAttachment extends CustomAttachment {
object.put("giftValueVos", giftReceiveInfo.getGiftValueVos());
}
object.put("currentTime", giftReceiveInfo.getCurrentTime());
if (giftReceiveInfo.getDrawFixedArray() != null) {
object.put("drawFixedArray", giftReceiveInfo.getDrawFixedArray());
}
return object;
}
}