|
|
|
@@ -4,20 +4,9 @@ import android.text.TextUtils;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
import com.yizhuan.xchat_android_core.gift.GiftModel;
|
|
|
|
|
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
|
|
|
|
import com.yizhuan.xchat_android_core.gift.bean.GiftList;
|
|
|
|
|
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiver;
|
|
|
|
|
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts;
|
|
|
|
|
import com.yizhuan.xchat_android_core.gift.bean.MultiGiftReceiveInfo;
|
|
|
|
|
import com.yizhuan.xchat_android_core.room.giftvalue.bean.IndexGiftValue;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import com.yizhuan.xchat_android_core.gift.bean.LuckyGiftList;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by chenran on 2017/10/25.
|
|
|
|
@@ -40,76 +29,12 @@ public class MultiLuckyGiftAttachment extends CustomAttachment {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void parseData(JSONObject data) {
|
|
|
|
|
multiLuckyGiftReceiveInfo = new LuckyBagGifts();
|
|
|
|
|
multiLuckyGiftReceiveInfo.setUid(data.getLong("uid"));
|
|
|
|
|
multiLuckyGiftReceiveInfo.setNick(data.getString("nick"));
|
|
|
|
|
multiLuckyGiftReceiveInfo.setGiftId(data.getInteger("giftId"));
|
|
|
|
|
multiLuckyGiftReceiveInfo.setGiftName(data.getString("giftName"));
|
|
|
|
|
multiLuckyGiftReceiveInfo.setGiftNum(data.getInteger("giftNum"));
|
|
|
|
|
if (data.containsKey("luckyGiftSvgaUrl")) {
|
|
|
|
|
multiLuckyGiftReceiveInfo.setLuckyGiftSvgaUrl(data.getString("luckyGiftSvgaUrl"));
|
|
|
|
|
multiLuckyGiftReceiveInfo = new Gson().fromJson(data.toJSONString(), LuckyBagGifts.class);
|
|
|
|
|
LuckyGiftList luckyGiftList = multiLuckyGiftReceiveInfo.getLuckyGiftList();
|
|
|
|
|
if (luckyGiftList != null) {
|
|
|
|
|
multiLuckyGiftReceiveInfo.setGiftList(luckyGiftList.getGiftList());
|
|
|
|
|
multiLuckyGiftReceiveInfo.setUser(luckyGiftList.getUser());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
multiLuckyGiftReceiveInfo.setShowAnimation(data.getBoolean("isShowAnimation") == null ? true : data.getBoolean("isShowAnimation"));
|
|
|
|
|
multiLuckyGiftReceiveInfo.setTargetNick(data.getString("targetNick") == null ? "" : data.getString("targetNick"));
|
|
|
|
|
multiLuckyGiftReceiveInfo.setTargetUid(data.getLong("targetUid") == null ? 0 : data.getLong("targetUid"));
|
|
|
|
|
|
|
|
|
|
JSONObject luckyGiftListObj = data.getJSONObject("luckyGiftList");
|
|
|
|
|
GiftReceiver giftReceiver = new Gson().fromJson(luckyGiftListObj.getJSONObject("user").toJSONString(), GiftReceiver.class);
|
|
|
|
|
multiLuckyGiftReceiveInfo.setUser(giftReceiver);
|
|
|
|
|
|
|
|
|
|
if (luckyGiftListObj.containsKey("giftList")) {
|
|
|
|
|
JSONArray giftListArray = luckyGiftListObj.getJSONArray("giftList");
|
|
|
|
|
String giftListStr = null;
|
|
|
|
|
if (giftListArray != null) {
|
|
|
|
|
giftListStr = giftListArray.toJSONString();
|
|
|
|
|
}
|
|
|
|
|
if (!TextUtils.isEmpty(giftListStr)) {
|
|
|
|
|
List<GiftList> giftList = new Gson().fromJson(giftListStr,
|
|
|
|
|
new TypeToken<List<GiftList>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
multiLuckyGiftReceiveInfo.setGiftList(giftList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONArray jsonArray = data.getJSONArray("targetUids");
|
|
|
|
|
List<Long> targetUids = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
Long uid = jsonArray.getLong(i);
|
|
|
|
|
targetUids.add(uid);
|
|
|
|
|
}
|
|
|
|
|
multiLuckyGiftReceiveInfo.setTargetUids(targetUids);
|
|
|
|
|
|
|
|
|
|
if (data.containsKey("displayGift")) {
|
|
|
|
|
JSONArray displayGiftListArray = data.getJSONArray("displayGift");
|
|
|
|
|
String displayGiftListStr = null;
|
|
|
|
|
if (displayGiftListArray != null) {
|
|
|
|
|
displayGiftListStr = displayGiftListArray.toJSONString();
|
|
|
|
|
}
|
|
|
|
|
if (!TextUtils.isEmpty(displayGiftListStr)) {
|
|
|
|
|
List<GiftInfo> displayGiftList = new Gson().fromJson(displayGiftListStr,
|
|
|
|
|
new TypeToken<List<GiftInfo>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
multiLuckyGiftReceiveInfo.setDisplayGift(displayGiftList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//礼物值数据处理
|
|
|
|
|
if (data.containsKey("giftValueVos")) {
|
|
|
|
|
JSONArray giftValueVosArray = data.getJSONArray("giftValueVos");
|
|
|
|
|
String giftValueVosStr = null;
|
|
|
|
|
if (giftValueVosArray != null) {
|
|
|
|
|
giftValueVosStr = giftValueVosArray.toJSONString();
|
|
|
|
|
}
|
|
|
|
|
if (!TextUtils.isEmpty(giftValueVosStr)) {
|
|
|
|
|
List<IndexGiftValue> giftValueVos = new Gson().fromJson(giftValueVosStr,
|
|
|
|
|
new TypeToken<List<IndexGiftValue>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
multiLuckyGiftReceiveInfo.setGiftValueVos(giftValueVos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
multiLuckyGiftReceiveInfo.setCurrentTime(data.getLong("currentTime"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|