涂鸦礼物消息协议修改

This commit is contained in:
huangjian
2022-08-22 17:12:50 +08:00
parent cd79f0ec3a
commit 41c57647ba
23 changed files with 222 additions and 108 deletions

View File

@@ -689,7 +689,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
msg: String?,
isKnap: Boolean,
isWholdMic: Boolean,
drawFixedArray: List<HashMap<String, String>>,
drawFixedArray: List<List<Int>>,
callback: SenGiftCallback
) {
val targetUids: MutableList<Long> = ArrayList()
@@ -697,14 +697,22 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
targetUids.add(micMemberInfos[i].account.toLong())
}
GiftModel.get()
.sendRoomGift(giftInfo.giftId, targetUids, number, msg, isKnap, isWholdMic,drawFixedArray)
.sendRoomGift(
giftInfo.giftId,
targetUids,
number,
msg,
isKnap,
isWholdMic,
drawFixedArray
)
.compose(bindUntilEvent(FragmentEvent.DESTROY))
.doOnError {
if (it is VipLevelNotEnoughException) {
dialogManager.showOkDialog("尚未达到赠送${giftInfo.giftName}所需贵族等级,所需贵族等级:${giftInfo.giftVipInfo?.vipName}")
}
}
.subscribe { throwable, _ ->
.subscribe { _, throwable ->
if (throwable != null) {
callback.onFail()
} else {

View File

@@ -100,7 +100,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
private Keyframe[] keyTrans;
private SvgaObjectPool mMagicViewPool;
private volatile Hashtable<Integer, MonsterAttackInfo> currentAnimationMap = new Hashtable<>();
private DrawGiftHelper drawGiftHelper;
public GiftV2View(Context context) {
@@ -282,12 +281,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
targetUsers.add(giftReceiver);
}
GiftReceiveInfo giftReceiveInfo = giftReceiveInfos.get(0);
if (giftReceiveInfo.getDrawFixedArray() != null) {
if (drawGiftHelper == null) {
drawGiftHelper = new DrawGiftHelper((Activity) context);
}
drawGiftHelper.prepareShowDrawGift(giftReceiveInfo.getDrawFixedArray(), false);
}
GiftInfo giftInfo = giftReceiveInfo.getGift();
if (totalCoin >= 520 || (giftInfo != null && giftInfo.isHasEffect())) {
Message msg = Message.obtain();

View File

@@ -1,6 +1,7 @@
package com.yizhuan.erban.avroom.widget
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.text.Layout
@@ -33,6 +34,7 @@ import com.yizhuan.erban.ui.utils.isDestroyed
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.erban.ui.utils.loadAnim
import com.yizhuan.erban.ui.widget.SimpleAnimListener
import com.yizhuan.erban.ui.widget.drawgift.DrawGiftHelper
import com.yizhuan.erban.utils.SpannableBuilder
import com.yizhuan.xchat_android_constants.XChatConstants
import com.yizhuan.xchat_android_core.auth.AuthModel
@@ -120,6 +122,9 @@ class RoomEffectView @JvmOverloads constructor(
private var isHideCarEffect = false
private val drawGiftHelper: DrawGiftHelper by lazy { DrawGiftHelper(context as Activity) }
private fun loopCarAnim() {
if (context.isDestroyed()) return
isSvgaPlaying = false
@@ -181,6 +186,16 @@ class RoomEffectView @JvmOverloads constructor(
RoomEvent.ROOM_CAR_EFFECT_SHOW -> {
isHideCarEffect = false
}
RoomEvent.DRAW_GIFT_EFFECT -> {
val drawGiftAttachment =
(roomEvent.chatRoomMessage?.attachment as? DrawGiftAttachment)
?: return@subscribe
drawGiftHelper.prepareShowDrawGift(
drawGiftAttachment.giftId,
drawGiftAttachment.drawFixedArray,
false
)
}
else -> {}
}
}

View File

@@ -11,7 +11,7 @@ import java.util.List;
public class OnGiftDialogBtnClickListenerWrapper implements GiftDialog.OnGiftDialogBtnClickListener {
@Override
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<HashMap<String, String>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<List<Integer>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
}

View File

@@ -55,7 +55,7 @@ public class GiftAction extends BaseAction implements GiftDialog.OnGiftDialogBtn
@SuppressLint("CheckResult")
@Override
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isknap, boolean isWholeMic, List<HashMap<String, String>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isknap, boolean isWholeMic, List<List<Integer>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
if (giftInfo == null) return;
GiftModel.get().sendPersonalGift(giftInfo.getGiftId(), micMemberInfos.get(0).getAccount(), number, msg, isknap)
.doOnError(throwable -> {

View File

@@ -993,6 +993,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (sendGiftButton == null) return;
sendGiftButton.setText("赠送");
sendGiftButton.setEnabled(true);
clearDrawGift();
}
@Override
@@ -1025,6 +1026,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (sendGiftButton == null) return;
sendGiftButton.setText("赠送");
sendGiftButton.setEnabled(true);
clearDrawGift();
}
@Override
@@ -1059,6 +1061,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (sendGiftButton == null) return;
sendGiftButton.setText("赠送");
sendGiftButton.setEnabled(true);
clearDrawGift();
}
@Override
@@ -1230,10 +1233,16 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
}
@Nullable
private List<HashMap<String, String>> getDrawFixedArray() {
private List<List<Integer>> getDrawFixedArray() {
return drawGiftHelper == null ? null : drawGiftHelper.getDrawFixedArray();
}
private void clearDrawGift() {
if (drawGiftHelper != null) {
drawGiftHelper.clearDrawGift();
}
}
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
@@ -1324,7 +1333,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
String msg,
boolean isKnap,
boolean isWholeMic,
List<HashMap<String, String>> drawFixedArray,
List<List<Integer>> drawFixedArray,
SenGiftCallback callback);
}

View File

@@ -27,6 +27,7 @@ import com.netease.nim.uikit.support.glide.GlideApp;
import com.yizhuan.erban.R;
import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -103,6 +104,8 @@ public class DrawGiftHelper {
public void lazyDrawGiftView(int bottomSheetHeight, DrawGiftView.DrawGiftListener onDrawGiftListener) {
if (drawGiftView == null) {
drawGiftView = new DrawGiftView(activity);
int newSize = ScreenUtil.dip2px(10);
drawGiftView.setDrawStrokeInterval(newSize);
drawGiftView.setOnDrawGiftListener(onDrawGiftListener);
drawGiftView.showInActivityWindow(activity, bottomSheetHeight);
}
@@ -131,7 +134,8 @@ public class DrawGiftHelper {
}
//子线程处理播放礼物的数据
public void prepareShowDrawGift(List<HashMap<String, String>> fixedArray, boolean insertToFirst) {
public void prepareShowDrawGift(int giftId, List<List<Integer>> fixedArray, boolean insertToFirst) {
if (ListUtils.isListEmpty(fixedArray)) return;
//把服务器推送来的"礼物位置json" 和 本地的 giftBeanList 一一对应上找到礼物的bitmap
final List<DrawGiftModel> allDrawGiftArray = new ArrayList<>();
@@ -146,32 +150,25 @@ public class DrawGiftHelper {
.getDefaultDisplay().getMetrics(displayMetrics);
float viewWidth = displayMetrics.widthPixels;
float viewHeight = displayMetrics.heightPixels;
GiftInfo giftBean = GiftModel.get().findGiftInfoById(giftId);
Bitmap thumbGiftBitmap = cacheBitmapByGiftIdMap.get(giftId);
//fixedArray 是服务器推送过来的礼物json
for (HashMap<String, String> fixedMap : fixedArray) {
//giftBeanList 是手机本地缓存的全部礼物列表
//我们要做的就是两个列表相互匹配根据礼物id找出礼物的bitmap通过glide
int giftId = Integer.parseInt(fixedMap.get("giftid"));
GiftInfo giftBean = GiftModel.get().findGiftInfoById(giftId);
for (List<Integer> fixedMap : fixedArray) {
//将服务器推送来的xy转成绝对像素坐标
DrawGiftModel drawGiftModel = new DrawGiftModel();
drawGiftModel.setX(Float.valueOf(fixedMap.get("x")) * viewWidth);
drawGiftModel.setY(Float.valueOf(fixedMap.get("y")) * viewHeight);
Bitmap thumbGiftBitmap = cacheBitmapByGiftIdMap.get(giftId);
drawGiftModel.setX(fixedMap.get(0) / 1000f * viewWidth);
drawGiftModel.setY(fixedMap.get(1) / 1000f * viewHeight);
if (thumbGiftBitmap != null) {
//缓存中就有bitmap
drawGiftModel.setGiftBitmap(thumbGiftBitmap);
} else {
//缓存没有bitmap
//从Glide里找出礼物的bitmap
FutureTarget<Bitmap> futureBitmap = Glide.with(activity).asBitmap()
.load(giftBean.getGiftUrl())
.submit();
try {
Bitmap bitmap = futureBitmap.get();
thumbGiftBitmap = obtainThumbBitmap(giftId, bitmap);
@@ -219,13 +216,19 @@ public class DrawGiftHelper {
}
}
public List<HashMap<String, String>> getDrawFixedArray() {
public List<List<Integer>> getDrawFixedArray() {
if (drawGiftView != null) {
return drawGiftView.transformGiftArrayFitScreen(activity);
}
return null;
}
public void clearDrawGift() {
if (drawGiftView != null) {
drawGiftView.removeAll();
}
}
private static class MyHandler extends Handler {

View File

@@ -91,7 +91,7 @@ public class DrawGiftPlayView extends View {
Message message = Message.obtain();
message.arg1 = 0;
message.what = DRAW_ONE_GIFT;
mHandler.sendMessageDelayed(message, 100);
mHandler.sendMessageDelayed(message, 50);
}
}
}
@@ -112,7 +112,7 @@ public class DrawGiftPlayView extends View {
Message message = Message.obtain();
message.arg1 = currentGiftShowIndex + 1;
message.what = DRAW_ONE_GIFT;
mHandler.sendMessageDelayed(message, 100);
mHandler.sendMessageDelayed(message, 50);
}
return true;

View File

@@ -193,7 +193,7 @@ public class DrawGiftView extends View {
public void removeAll() {
strokeFirstPositionArray.clear();
allDrawGiftArray.clear();
invalidate();
postInvalidate();
}
//移除最后一笔
@@ -266,23 +266,22 @@ public class DrawGiftView extends View {
}
//由于不同手机屏幕尺寸不同如果礼物画在大屏幕的最右边X很大在小屏幕上绘制礼物的时候X会超出屏幕。因此在这里转成百分比再上传给服务器
public List<HashMap<String, String>> transformGiftArrayFitScreen(Context context) {
public List<List<Integer>> transformGiftArrayFitScreen(Context context) {
DisplayMetrics displayMetrics = new DisplayMetrics();
((WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay().getMetrics(displayMetrics);
//fixedArray是需要转成json发送给服务器的
List<HashMap<String, String>> fixedArray = new ArrayList<>();
List<List<Integer>> fixedArray = new ArrayList<>();
float viewWidth = displayMetrics.widthPixels;
float viewHeight = displayMetrics.heightPixels;
HashMap<String, String> param = null;
List<Integer> param = null;
for (DrawGiftModel giftModel : allDrawGiftArray) {
//x 和 y转为屏幕比例
param = new HashMap<>();
param.put("x", String.valueOf(((int) ((giftModel.getX() / viewWidth) * 1000)) / 1000f));
param.put("y", String.valueOf(((int) ((giftModel.getY() / viewHeight) * 1000)) / 1000f));
param.put("giftid", String.valueOf(giftModel.getgiftId()));
param = new ArrayList<>();
param.add((int) ((giftModel.getX() / viewWidth) * 1000));
param.add((int) ((giftModel.getY() / viewHeight) * 1000));
fixedArray.add(param);
}
return fixedArray;

View File

@@ -184,7 +184,7 @@ public class MWTeamRoomMessageAct extends BaseMessageActivity implements IMWTeam
new OnGiftDialogBtnClickListenerWrapper() {
@SuppressLint("CheckResult")
@Override
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<HashMap<String, String>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<List<Integer>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
if (giftInfo == null) return;
if (mMwChatInfo != null) {

View File

@@ -207,7 +207,7 @@ public class MiniWorldTeamMessageActivity extends BaseMessageActivity implements
new OnGiftDialogBtnClickListenerWrapper() {
@SuppressLint("CheckResult")
@Override
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<HashMap<String, String>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<List<Integer>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
if (giftInfo == null) return;
if (mMwChatInfo != null) {

View File

@@ -304,7 +304,7 @@ public class PublicChatHallMessageFragment extends TFragment implements ModulePr
new OnGiftDialogBtnClickListenerWrapper() {
@SuppressLint("CheckResult")
@Override
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<HashMap<String, String>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
public void onSendGiftBtnClick(GiftInfo giftInfo, ArrayList<MicMemberInfo> micMemberInfos, int number, String msg, boolean isKnap, boolean isWholeMic, List<List<Integer>> drawFixedArray, GiftDialog.SenGiftCallback callback) {
if (giftInfo == null) return;
boolean canUseNobleGiftOrNot = GiftModel.get().canUseNobleGiftOrNot(giftInfo);
if (canUseNobleGiftOrNot) {

View File

@@ -1355,6 +1355,11 @@ public final class IMNetEaseManager {
addMessages(msg);
}
break;
case CUSTOM_MSG_DRAW_GIFT_EFFECT:
if (customAttachment.getSecond() == CUSTOM_MSG_SUB_TYPE_DRAW_GIFT_EFFECT) {
noticeRoomEvent(msg, RoomEvent.DRAW_GIFT_EFFECT);
}
break;
default:
break;
}

View File

@@ -309,7 +309,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
boolean isKnap,
boolean isWholeMic,
String chatSessionId,
List<HashMap<String, String>> drawFixedArray) {
List<List<Integer>> drawFixedArray) {
if (ListUtils.isListEmpty(targetUids)) {
return Single.error(new Throwable("targetUids is empty"));
}
@@ -365,11 +365,9 @@ 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));
}
switch (sendType) {
case GiftSendType.TYPE_ANCHOR:
case GiftSendType.TYPE_MIC:
@@ -400,6 +398,9 @@ public class GiftModel extends BaseModel implements IGiftModel {
}
break;
}
if (!ListUtils.isListEmpty(drawFixedArray)) {
GiftToolbox.sendDrawGiftRoomMessage(giftId, drawFixedArray);
}
return Single.just(serviceResult);
} else {
if (serviceResult.getCode() == BalanceNotEnoughExeption.code) {
@@ -459,7 +460,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
String msg,
boolean isKnap,
boolean isWholeMic,
List<HashMap<String, String>> drawFixedArray) {
List<List<Integer>> drawFixedArray) {
Log.e("GiftDialog", "sendRoomGift() called with: giftId = [" + giftId + "], targetUids = [" + targetUids + "], giftNum = [" + giftNum + "], msg = [" + msg + "], isKnap = [" + isKnap + "], isWholeMic = [" + isWholeMic + "]");
return sendGift(
giftId,

View File

@@ -89,7 +89,7 @@ public interface IGiftModel {
boolean isKnap,
boolean isWholeMic,
String chatSessionId,
List<HashMap<String, String>> drawFixedArray);
List<List<Integer>> drawFixedArray);
/**
* 房间内发送礼物
@@ -106,7 +106,7 @@ public interface IGiftModel {
String msg,
boolean isKnap,
boolean isWholeMic,
List<HashMap<String, String>> drawFixedArray);
List<List<Integer>> drawFixedArray);
/**
* 在单聊界面送礼物

View File

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

View File

@@ -20,12 +20,14 @@ 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.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.DrawGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftBatchAttachment;
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.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
import com.yizhuan.xchat_android_core.manager.RoomEvent;
import com.yizhuan.xchat_android_core.public_chat_hall.manager.PublicChatHallDataManager;
import com.yizhuan.xchat_android_core.public_chat_hall.model.PublicChatHallModel;
import com.yizhuan.xchat_android_core.retry.ImRetryManager;
@@ -35,6 +37,7 @@ import com.yizhuan.xchat_android_core.user.bean.UserInfo;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import io.reactivex.Single;
@@ -45,6 +48,44 @@ import io.reactivex.Single;
* @Date 2019/3/8
*/
public class GiftToolbox {
//单人礼物公屏
public static final int CUSTOM_MSG_HEADER_TYPE_GIFT = 3;
public static final int CUSTOM_MSG_SUB_TYPE_SEND_GIFT = 31; //普通单人送礼公屏
public static final int CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT = 33;//单人福袋送礼公屏
//多人礼物公屏
public static final int CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT = 12;
//普通
public static final int CUSTOM_MSG_SUB_TYPE_BATCH_SEND_GIFT = 123;// 普通多人
public static final int CUSTOM_MSG_SUB_TYPE_SEND_MULTI_GIFT = 121;//普通全麦
//福袋
public static final int CUSTOM_MSG_SUB_TYPE_SEND_MULTI_LUCK_GIFT = 124;// 福袋多人
public static final int CUSTOM_MSG_SUB_TYPE_SEND_ALL_MIC_LUCKY_GIFT = 122;// 福袋全麦
/**
* 收到普通礼物
*/
public static final int RECEIVE_NORMALE_GIFT = 34;
/**
* 收到普通全麦礼物
*/
public static final int RECEIVE_ALL_MIC__NORMALEI_GIFT = 35;
/**
* 收到普通多人礼物
*/
public static final int RECEIVE_MUTLT_NORMALEI_GIFT = 53;
/**
* 收到个人福袋礼物
*/
public static final int RECEIVE_LUCKY_GIFT = 61;
/**
* 收到多人福袋礼物
*/
public static final int RECEIVE_MULTI_LUCKY_GIFT = 62;
/**
* 收到全麦福袋礼物
*/
public static final int RECEIVE_ALL_MIC_LUCKY_GIFT = 64;
public static MultiGiftReceiveInfo transformToMultiGiftReceiveInfo(GiftMultiReceiverInfo giftMultiReceiverInfo) {
MultiGiftReceiveInfo giftReceiveInfo = new MultiGiftReceiveInfo();
giftReceiveInfo.setUid(giftMultiReceiverInfo.getUid());
@@ -105,8 +146,6 @@ public class GiftToolbox {
giftReceiveInfo.setDisplayGift(giftMultiReceiverInfo.getDisplayGift());
giftReceiveInfo.setGiftValueVos(giftMultiReceiverInfo.getGiftValueVos());
giftReceiveInfo.setCurrentTime(giftMultiReceiverInfo.getCurrentTime());
giftReceiveInfo.setDrawFixedArray(giftMultiReceiverInfo.getDrawFixedArray());
return giftReceiveInfo;
}
@@ -181,6 +220,31 @@ public class GiftToolbox {
}
/**
* 发送涂鸦礼物特效消息
*/
public static void sendDrawGiftRoomMessage(int giftId, List<List<Integer>> drawFixedArray) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo == null) return;
DrawGiftAttachment giftAttachment = new DrawGiftAttachment(
CustomAttachment.CUSTOM_MSG_DRAW_GIFT_EFFECT,
CustomAttachment.CUSTOM_MSG_SUB_TYPE_DRAW_GIFT_EFFECT
);
giftAttachment.setGiftId(giftId);
giftAttachment.setDrawFixedArray(drawFixedArray);
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
// 聊天室id
roomInfo.getRoomId() + "",
giftAttachment
);
ImRetryManager.sendRoomGiftMsg(message)
.doOnSuccess(retryChatRoomMessage -> {
// 送礼物的人自己的涂鸦特效
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.DRAW_GIFT_EFFECT);
})
.subscribe();
}
/**
* 发送个多人送普通礼物的消息到公屏
*
@@ -227,7 +291,6 @@ public class GiftToolbox {
}
}
/**
* 发送全麦普通礼物的公屏消息
*
@@ -264,13 +327,12 @@ public class GiftToolbox {
}
}
/**
* 发送单人送福袋礼物的消息到公屏
*
* @param giftReceiveInfo
*/
public static void sendLuckyGiftRoomMessage(GiftMultiReceiverInfo giftReceiveInfo,int first,int second) {
public static void sendLuckyGiftRoomMessage(GiftMultiReceiverInfo giftReceiveInfo, int first, int second) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo != null && giftReceiveInfo != null) {
@@ -325,7 +387,7 @@ public class GiftToolbox {
*
* @param giftReceiveInfo
*/
public static void sendMultiLuckyGiftRoomMessage(GiftMultiReceiverInfo giftReceiveInfo,int first,int second) {
public static void sendMultiLuckyGiftRoomMessage(GiftMultiReceiverInfo giftReceiveInfo, int first, int second) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo != null && giftReceiveInfo != null) {
@@ -373,6 +435,7 @@ public class GiftToolbox {
}
}
}
//===================================================================================
/**
* 私聊界面发送礼物消息
@@ -451,7 +514,6 @@ public class GiftToolbox {
/**
* 群聊送礼消息
*
*/
public static Single<IMMessage> sendGiftTeamMessage(String sessionId, GiftMultiReceiverInfo multiGiftReceiveInfo) {
UserInfo myUserInfo = UserModel.get().getCacheLoginUserInfo();
@@ -492,48 +554,4 @@ public class GiftToolbox {
return IMNetEaseManager.get()
.sendMessageSingle(imMessage);
}
//单人礼物公屏
public static final int CUSTOM_MSG_HEADER_TYPE_GIFT = 3;
public static final int CUSTOM_MSG_SUB_TYPE_SEND_GIFT = 31; //普通单人送礼公屏
public static final int CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT = 33;//单人福袋送礼公屏
//多人礼物公屏
public static final int CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT = 12;
//普通
public static final int CUSTOM_MSG_SUB_TYPE_BATCH_SEND_GIFT = 123;// 普通多人
public static final int CUSTOM_MSG_SUB_TYPE_SEND_MULTI_GIFT = 121;//普通全麦
//福袋
public static final int CUSTOM_MSG_SUB_TYPE_SEND_MULTI_LUCK_GIFT = 124;// 福袋多人
public static final int CUSTOM_MSG_SUB_TYPE_SEND_ALL_MIC_LUCKY_GIFT = 122;// 福袋全麦
/**
* 收到普通礼物
*/
public static final int RECEIVE_NORMALE_GIFT = 34;
/**
* 收到普通全麦礼物
*/
public static final int RECEIVE_ALL_MIC__NORMALEI_GIFT = 35;
/**
* 收到普通多人礼物
*/
public static final int RECEIVE_MUTLT_NORMALEI_GIFT = 53;
//===================================================================================
/**
* 收到个人福袋礼物
*/
public static final int RECEIVE_LUCKY_GIFT = 61;
/**
* 收到多人福袋礼物
*/
public static final int RECEIVE_MULTI_LUCKY_GIFT = 62;
/**
* 收到全麦福袋礼物
*/
public static final int RECEIVE_ALL_MIC_LUCKY_GIFT = 64;
}

View File

@@ -14,6 +14,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_MSG_CHATTER_BOX_DROP;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CHATTER_BOX_INIT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAGON_BAR;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAW_GIFT_EFFECT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_MEMBER_COUNT;
@@ -56,6 +57,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_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_DIAMOND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_DRAW_GIFT_EFFECT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_RECEIVE_LUCKY_MONEY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ADD_BLACK;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_KICK_ROOM;
@@ -590,6 +592,11 @@ public class CustomAttachParser implements MsgAttachmentParser {
case CUSTOM_MSG_RADISH:
attachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_RADISH, second);
break;
case CUSTOM_MSG_DRAW_GIFT_EFFECT:
if (second == CUSTOM_MSG_SUB_TYPE_DRAW_GIFT_EFFECT) {
attachment = new DrawGiftAttachment(first, second);
}
break;
default:
LogUtils.e("未定义的first,请现在CustomAttachParser中解析first=" + first + " second=" + second);
break;

View File

@@ -16,21 +16,29 @@ public class CustomAttachment implements MsgAttachment {
public static final int CUSTOM_MSG_SUB_TYPE_AUCTION_START = 11;
public static final int CUSTOM_MSG_SUB_TYPE_AUCTION_FINISH = 12;
public static final int CUSTOM_MSG_SUB_TYPE_AUCTION_UPDATE = 13;
public static final int CUSTOM_MSG_HEADER_TYPE_ROOM_TIP = 2;
public static final int CUSTOM_MSG_SUB_TYPE_ROOM_TIP_SHARE_ROOM = 21;
public static final int CUSTOM_MSG_SUB_TYPE_ROOM_TIP_ATTENTION_ROOM_OWNER = 22;
public static final int CUSTOM_MSG_HEADER_TYPE_GIFT = 3;
public static final int CUSTOM_MSG_SUB_TYPE_SEND_GIFT = 31; //普通单人送礼公屏
public static final int CUSTOM_MSG_ALL_SERVICE_GIFT = 32;
public static final int CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT = 34;//单人福袋送礼公屏
public static final int CUSTOM_MSG_HEADER_TYPE_ACCOUNT = 5;
public static final int CUSTOM_MSG_HEADER_TYPE_OPEN_ROOM_NOTI = 6;
public static final int CUSTOM_MSG_HEADER_TYPE_QUEUE = 8;
public static final int CUSTOM_MSG_HEADER_TYPE_QUEUE_INVITE = 81;
public static final int CUSTOM_MSG_HEADER_TYPE_QUEUE_KICK = 82;
public static final int CUSTOM_MSG_HEADER_TYPE_FACE = 9;
public static final int CUSTOM_MSG_SUB_TYPE_FACE_SEND = 91;
public static final int CUSTOM_MSG_HEADER_TYPE_NOTICE = 10;
public static final int CUSTOM_MSG_HEADER_TYPE_PACKET = 11;
public static final int CUSTOM_MSG_SUB_TYPE_PACKET_FIRST = 111;
//送礼物
@@ -400,6 +408,10 @@ public class CustomAttachment implements MsgAttachment {
public static final int CUSTOM_MSG_GIFT_COMPOUND = 93;
public static final int CUSTOM_MSG_SUB_GIFT_COMPOUND = 931;
public static final int CUSTOM_MSG_DRAW_GIFT_EFFECT = 94;
public static final int CUSTOM_MSG_SUB_TYPE_DRAW_GIFT_EFFECT = 941;
/**
* 自定义消息附件的类型,根据该字段区分不同的自定义消息
*/

View File

@@ -0,0 +1,52 @@
package com.yizhuan.xchat_android_core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import java.util.List;
/**
* @author chenran
* @date 2017/7/28
*/
public class DrawGiftAttachment extends CustomAttachment {
private int giftId;
private List<List<Integer>> drawFixedArray;
public DrawGiftAttachment(int first, int second) {
super(first, second);
}
public int getGiftId() {
return giftId;
}
public void setGiftId(int giftId) {
this.giftId = giftId;
}
public List<List<Integer>> getDrawFixedArray() {
return drawFixedArray;
}
public void setDrawFixedArray( List<List<Integer>> drawFixedArray) {
this.drawFixedArray = drawFixedArray;
}
@Override
protected void parseData(JSONObject data) {
giftId = data.getIntValue("giftId");
drawFixedArray = data.getObject("drawFixedArray", new TypeReference<List<List<Integer>>>() {
}.getType());
}
@Override
protected JSONObject packData() {
JSONObject object = new JSONObject();
object.put("drawFixedArray", drawFixedArray);
object.put("giftId", giftId);
return object;
}
}

View File

@@ -79,10 +79,6 @@ 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"));
}
@@ -103,9 +99,6 @@ 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;
}
}

View File

@@ -245,6 +245,8 @@ public class RoomEvent {
//开宝箱横幅,SVGA背景的
public static final int RADISH_NOTIFY_SVGA = 97;
public static final int DRAW_GIFT_EFFECT = 98;
private int event = NONE;
private int micPosition = Integer.MIN_VALUE;
private int posState = -1;