[Modify]增加免费礼物961推送

This commit is contained in:
wushaocheng
2022-12-16 11:15:56 +08:00
parent b3877fd2b0
commit a33918e520
8 changed files with 108 additions and 4 deletions

View File

@@ -74,6 +74,7 @@ import com.yizhuan.xchat_android_core.family.bean.FamilyInfo;
import com.yizhuan.xchat_android_core.family.event.FamilyMineEvent;
import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapFreeGiftDataEvent;
import com.yizhuan.xchat_android_core.helper.AtProxy;
import com.yizhuan.xchat_android_core.im.custom.bean.ActivityTimerAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.AssistantAttachment;
@@ -99,8 +100,12 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFreeGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFreeGiftMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomGiftValueAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomInfoAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTipAttachment;
@@ -1337,6 +1342,13 @@ public final class IMNetEaseManager {
noticeRoomEvent(msg, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY);
}
break;
case ROOM_FREE_GIFT:
if(second == ROOM_FREE_GIFT_CHANGE){
RoomFreeGiftAttachment freeGiftAttachment = (RoomFreeGiftAttachment) attachment;
RoomFreeGiftMsgBean bean = freeGiftAttachment.getRoomFreeGiftMsgInfo();
EventBus.getDefault().post(new UpdateKnapFreeGiftDataEvent(bean));
}
break;
default:
break;
}

View File

@@ -637,17 +637,17 @@ public class GiftModel extends BaseModel implements IGiftModel {
return api.getFreeGift().compose(new Transformer<>()).doOnSuccess(response -> {
if (response.isSuccess()) {
giftFreeInfo = response.getData();
startFreeGiftCountDown(giftFreeInfo.getGiftId(), isReset);
if(isReset){
if (isReset) {
EventBus.getDefault().post(new UpdateKnapFreeGiftNumEvent(giftFreeInfo.getGiftId(), true));
}
startFreeGiftCountDown(giftFreeInfo.getGiftId());
}
});
}
private CountDownTimer countDownTimer;
private void startFreeGiftCountDown(int giftId, boolean isReset) {
private void startFreeGiftCountDown(int giftId) {
cancelCountDownTimer();
if (giftFreeInfo.getCurStage() < giftFreeInfo.getMaxStage()) {
if (giftFreeInfo.getCurStageSecond() > 0) {

View File

@@ -0,0 +1,18 @@
package com.yizhuan.xchat_android_core.gift.event;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFreeGiftMsgBean;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 更新背包免费礼物事件
* Created by wushaocheng on 2022/12/14.
*/
@AllArgsConstructor
@Data
public class UpdateKnapFreeGiftDataEvent {
private RoomFreeGiftMsgBean roomFreeGiftMsgBean;
}

View File

@@ -84,6 +84,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_NOTI_SUB_GAME_ATTACK;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_NOTI_SUB_GAME_RESULT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.ROOM_FREE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.ROOM_FREE_GIFT_CHANGE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.ROOM_FREE_GIFT_REST;
import com.alibaba.fastjson.JSON;
@@ -619,13 +620,15 @@ public class CustomAttachParser implements MsgAttachmentParser {
switch (second) {
case CUSTOM_MSG_LUCKY_SEA_GIFT_ROOM_NOTIFY:
case CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_NOTIFY:
attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_LUCKY_SEA, second);
attachment = new RoomLuckySeaAttachment(first, second);
break;
}
break;
case ROOM_FREE_GIFT:
if (second == ROOM_FREE_GIFT_REST) {
GiftModel.get().getFreeGift(true).subscribe();
}else if(second == ROOM_FREE_GIFT_CHANGE){
attachment = new RoomFreeGiftAttachment(first, second);
}
break;
default:

View File

@@ -426,6 +426,7 @@ public class CustomAttachment implements MsgAttachment {
//免费礼物倒计时重置推送
public static final int ROOM_FREE_GIFT = 96;
public static final int ROOM_FREE_GIFT_REST = 960;
public static final int ROOM_FREE_GIFT_CHANGE = 961;
/**
* 自定义消息附件的类型,根据该字段区分不同的自定义消息

View File

@@ -0,0 +1,33 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
/**
* 免费礼物
* Created by wushaocheng on 2022/12/16.
*/
public class RoomFreeGiftAttachment extends CustomAttachment {
private RoomFreeGiftMsgBean roomFreeGiftMsgBean;
public RoomFreeGiftAttachment(int first, int second) {
super(first, second);
}
@Override
protected void parseData(JSONObject data) {
roomFreeGiftMsgBean = new Gson().fromJson(data.toJSONString(), RoomFreeGiftMsgBean.class);
}
@Override
protected JSONObject packData() {
String jsonStr = new Gson().toJson(roomFreeGiftMsgBean);
return JSONObject.parseObject(jsonStr);
}
public RoomFreeGiftMsgBean getRoomFreeGiftMsgInfo() {
return roomFreeGiftMsgBean;
}
}

View File

@@ -0,0 +1,11 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import lombok.Data;
@Data
public class RoomFreeGiftMsgBean {
private int giftId;//礼物id
private String giftName;//礼物名称
private String giftUrl;//礼物icon
private long goldPrice;//礼物价格
}