新增开箱子五级礼物SVGA横幅

This commit is contained in:
huangjian
2020-12-10 15:26:02 +08:00
parent e302e0a007
commit 991263da91
13 changed files with 243 additions and 266 deletions

Binary file not shown.

View File

@@ -33,6 +33,7 @@ import androidx.viewpager.widget.ViewPager;
import com.coorchice.library.SuperTextView;
import com.netease.nim.uikit.common.util.string.StringUtil;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
@@ -60,6 +61,7 @@ import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.ui.widget.ButtonItem;
import com.yizhuan.erban.ui.widget.ShareDialog;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.erban.utils.SpannableBuilder;
import com.yizhuan.xchat_android_constants.XChatConstants;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.auth.AuthModel;
@@ -67,6 +69,7 @@ import com.yizhuan.xchat_android_core.decoration.car.bean.CarInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.gift.bean.MultiGiftReceiveInfo;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent;
@@ -81,6 +84,7 @@ import com.yizhuan.xchat_android_core.magic.bean.MultiMagicReceivedInfo;
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.monsterhunting.SimpleAnimationListener;
import com.yizhuan.xchat_android_core.praise.PraiseModel;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.room.game.GameEvent;
@@ -94,6 +98,7 @@ import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
import com.yizhuan.xchat_android_library.rxbus.RxBus;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import com.yizhuan.xchat_android_library.utils.LogUtil;
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
import org.greenrobot.eventbus.EventBus;
@@ -132,7 +137,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
public static final int SELECT_CONTRIBUTE_LIST = 1;
private HomePartyRoomFragment roomFragment;
private HomePartyUserListFragment listFragment;
private TextView roomTitle;
private TextView roomId;
@@ -186,8 +190,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
updateOnlineNumberView(0);
if (roomFragment != null)
roomFragment.onNewIntent(intent);
if (listFragment != null)
listFragment.onNewIntent(intent);
}
@Override
@@ -230,7 +232,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
}
roomId = mView.findViewById(R.id.room_id);
roomBack = mView.findViewById(R.id.room_back);
// giftView = mView.findViewById(R.id.gift_view);
mSvgaCar = mView.findViewById(R.id.room_car_svga);
mSvgaMemberIn = mView.findViewById(R.id.room_menber_in_svga);
mSvgaLevelUp = mView.findViewById(R.id.room_level_up_svga);
@@ -396,7 +397,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
if (!AvRoomDataManager.get().haveSelfChange && AvRoomDataManager.get().mCurrentRoomInfo != null) {
AvRoomDataManager.get().mIsNeedGiftEffect = AvRoomDataManager.get().mCurrentRoomInfo.isHasAnimationEffect();
}
//砸金蛋横幅通知这个订阅不能在onPause里面取消,单独写个...
IMNetEaseManager.get().getChatRoomEventObservable()
.compose(bindToLifecycle())
.subscribe(roomEvent -> {
@@ -404,9 +405,11 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
int event = roomEvent.getEvent();
switch (event) {
case RoomEvent.BOX_NOTIFY:
//砸金蛋横幅通知这个订阅不能在onPause里面取消,单独写个...
addBoxNotify(roomEvent.getChatRoomMessage());
break;
case RoomEvent.BOX_NOTIFY_SVGA:
addBoxNotifyBySVGA(roomEvent.getChatRoomMessage());
break;
case RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE:
case RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE:
//全服福袋
@@ -849,40 +852,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
}
}
private class MyOnPageChangeListener implements ViewPager.OnPageChangeListener {
private int selectPosition = -1;
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
selectPosition = position;
selectPage = position;
if (position == 1 && listFragment != null) {
if (selectContent == SELECT_CONTRIBUTE_LIST) {
listFragment.showPage(HomePartyUserListFragment.SHOW_PAGE_CONTRIBUTE_LIST);
} else if (selectContent == SELECT_ONLINE_LIST) {
listFragment.showPage(HomePartyUserListFragment.SHOW_PAGE_ONLINE_LIST);
}
}
selectContent = SELECT_DEFAULT;
}
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_IDLE && selectPosition >= 0) {
if (listFragment != null) {
listFragment.setViewPagerPosition(selectPosition);
}
} else if (state == ViewPager.SCROLL_STATE_DRAGGING) {
selectPosition = -1;
}
}
}
@Override
public void onShowActivity(List<BannerInfo> dialogInfos) {
if (roomFragment != null && roomFragment.isAdded()) {
@@ -979,8 +948,12 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
private Disposable boxDisposable;
private boolean isCreate;
private List<ChatRoomMessage> messagesBoxSVGA;
private Disposable boxSVGADisposable;
private boolean isBoxSVGACreate;
private Animation animationLuckyGift;
private List<SuperTextView> messagesLuckyGift;
private List<ChatRoomMessage> messagesLuckyGift;
private boolean isCreateLuckyGift;
private Disposable disposableLuckyGift;
@@ -992,6 +965,54 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
private boolean isCreateLevelUp;
private Disposable disposableLevelUp;
/**
* 开福袋飘屏
*
* @param chatRoomMessage
*/
private void addLuckyBagNotify(ChatRoomMessage chatRoomMessage) {
if (messagesLuckyGift == null) messagesLuckyGift = new ArrayList<>();
messagesLuckyGift.add(chatRoomMessage);
if (disposableLuckyGift == null || messagesLuckyGift.size() == 1) {
isCreateLuckyGift = true;
disposableLuckyGift = Observable.interval(0, 6, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(aLong -> {
if (messagesLuckyGift.size() > 0 && !isCreateLuckyGift)
messagesLuckyGift.remove(0);//如果不是新创建的Observable发送的数据,需要移除第一个
isCreateLuckyGift = false;
})
.takeWhile(aLong -> messagesLuckyGift.size() > 0 && messagesLuckyGift.get(0) != null)
.subscribe(aLong -> showLuckyBagNotify(messagesLuckyGift.get(0)));
}
}
private void showLuckyBagNotify(ChatRoomMessage message) {
if (animationLuckyGift == null)
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
RoomReceivedLuckyGiftAttachment attachment = (RoomReceivedLuckyGiftAttachment) message.getAttachment();
LuckyBagNoticeInfo noticeInfo = attachment.getLuckyBagNoticeInfo();
if (noticeInfo == null) return;
SpannableBuilder text = new SpannableBuilder()
.append("哇偶! ", new ForegroundColorSpan(Color.WHITE))
.append(noticeInfo.getNick() + " ", new ForegroundColorSpan(getResources().getColor(R.color.notice_nick)))
.append("通过", new ForegroundColorSpan(Color.WHITE))
.append(noticeInfo.getLuckyBagName() + " ", new ForegroundColorSpan(Color.WHITE))
.append("开出了", new ForegroundColorSpan(Color.WHITE))
.append(noticeInfo.getGiftName(), new ForegroundColorSpan(getResources().getColor(R.color.notice_gift)));
gameMainBinding.tvLuckyGiftNotify.setText(text.build());
gameMainBinding.flLuckyGiftNotify.setVisibility(View.VISIBLE);
gameMainBinding.flLuckyGiftNotify.startAnimation(animationLuckyGift);
animationLuckyGift.setAnimationListener(new SimpleAnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
gameMainBinding.flLuckyGiftNotify.setVisibility(View.GONE);
}
});
}
/**
* 幸运池飘屏
*
@@ -1015,37 +1036,87 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
}
private void showBoxNotify(ChatRoomMessage chatRoomMessage) {
// if (AvRoomDataManager.get().mCurrentRoomInfo == null) return;
SuperTextView textView = (SuperTextView) LayoutInflater.from(mContext).inflate(R.layout.layout_box_notify_pic, null);
RoomBoxPrizeAttachment attachment = (RoomBoxPrizeAttachment) chatRoomMessage.getAttachment();
// 内容
MessageView.SpannableBuilder text = new MessageView.SpannableBuilder(textView)
SpannableBuilder text = new SpannableBuilder()
.append("厉害了! ", new ForegroundColorSpan(Color.WHITE))
.append(attachment.getNick() + " ", new ForegroundColorSpan(getResources().getColor(R.color.notice_nick)))
.append(attachment.getBoxTypeStr() + " ", new ForegroundColorSpan(Color.WHITE))
.append(attachment.getPrizeName(), new ForegroundColorSpan(getResources().getColor(R.color.notice_gift)))
.append("x" + attachment.getPrizeNum(), new ForegroundColorSpan(Color.WHITE));
textView.setText(text.build());
gameMainBinding.tvBoxNotify.setText(text.build());
if (animation == null)
animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
gameMainBinding.flBoxNotify.removeAllViews();
gameMainBinding.flBoxNotify.setVisibility(View.VISIBLE);
gameMainBinding.flBoxNotify.addView(textView);
gameMainBinding.flBoxNotify.startAnimation(animation);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
animation.setAnimationListener(new SimpleAnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
gameMainBinding.flBoxNotify.removeAllViews();
gameMainBinding.flBoxNotify.setVisibility(View.GONE);
}
});
}
/**
* 幸运池飘屏 五级 SVGA背景的
*
* @param chatRoomMessage
*/
private void addBoxNotifyBySVGA(ChatRoomMessage chatRoomMessage) {
if (messagesBoxSVGA == null) messagesBoxSVGA = new ArrayList<>();
messagesBoxSVGA.add(chatRoomMessage);
if (boxSVGADisposable == null || messagesBoxSVGA.size() == 1) {
isBoxSVGACreate = true;
boxSVGADisposable = Observable.interval(0, 6, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(aLong -> {
if (messagesBoxSVGA.size() > 0 && !isBoxSVGACreate)
messagesBoxSVGA.remove(0);//如果不是新创建的Observable发送的数据,需要移除第一个
isBoxSVGACreate = false;
})
.takeWhile(aLong -> messagesBoxSVGA.size() > 0 && messagesBoxSVGA.get(0) != null)
.subscribe(aLong -> showBoxNotifyBySVGA(messagesBoxSVGA.get(0)));
}
}
private void showBoxNotifyBySVGA(ChatRoomMessage chatRoomMessage) {
RoomBoxPrizeAttachment attachment = (RoomBoxPrizeAttachment) chatRoomMessage.getAttachment();
SpannableBuilder text = new SpannableBuilder()
.append("厉害了! ", new ForegroundColorSpan(Color.WHITE))
.append(attachment.getNick() + " ", new ForegroundColorSpan(getResources().getColor(R.color.notice_nick)))
.append(attachment.getBoxTypeStr() + " ", new ForegroundColorSpan(Color.WHITE))
.append(attachment.getPrizeName(), new ForegroundColorSpan(getResources().getColor(R.color.notice_gift)))
.append("x" + attachment.getPrizeNum(), new ForegroundColorSpan(Color.WHITE));
mSVGAParser.decodeFromAssets("svga/box_notify.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@Nullable SVGAVideoEntity svgaVideoEntity) {
gameMainBinding.svgaBoxNotify.setVisibility(View.VISIBLE);
gameMainBinding.svgaBoxNotify.setLoops(1);
gameMainBinding.svgaBoxNotify.setClearsAfterStop(true);
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色
textPaint.setTextSize(24);//字体大小
dynamicEntity.setDynamicText(new StaticLayout(
text.build(),
0,
text.build().length(),
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "xtc_copywriting");
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
gameMainBinding.svgaBoxNotify.setImageDrawable(drawable);
gameMainBinding.svgaBoxNotify.stepToFrame(0, true);
gameMainBinding.svgaBoxNotify.startAnimation();
}
@Override
public void onAnimationRepeat(Animation animation) {
public void onError() {
}
});
@@ -1123,7 +1194,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
private void playMemberInAnim(String text, String path) {
mSVGAParser.decodeFromAssets(path, new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@javax.annotation.Nullable SVGAVideoEntity svgaVideoEntity) {
public void onComplete(@Nullable SVGAVideoEntity svgaVideoEntity) {
mSvgaMemberIn.setVisibility(View.VISIBLE);
mSvgaMemberIn.setLoops(1);
mSvgaMemberIn.setClearsAfterStop(true);
@@ -1131,10 +1202,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色
textPaint.setTextSize(22);//字体大小
// textPaint.setShadowLayer(3, 2, 2, 0xff000000);//字体阴影,不需要可以不用设置
// dynamicEntity.setDynamicText(text, textPaint, "room_text");
// SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
// spannableStringBuilder.setSpan(new ForegroundColorSpan(0xfff6ff00), 0, 4, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
dynamicEntity.setDynamicText(new StaticLayout(
text,
0,
@@ -1150,27 +1217,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
mSvgaMemberIn.setImageDrawable(drawable);
mSvgaMemberIn.stepToFrame(0, true);
mSvgaMemberIn.startAnimation();
mSvgaMemberIn.setCallback(new SVGACallback() {
@Override
public void onPause() {
}
@Override
public void onFinished() {
// mSvgaMemberIn.setVisibility(View.GONE);
}
@Override
public void onRepeat() {
}
@Override
public void onStep(int i, double v) {
}
});
}
@Override
@@ -1268,75 +1314,6 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
}
}
/**
* 开福袋飘屏
*
* @param chatRoomMessage
*/
private void addLuckyBagNotify(ChatRoomMessage chatRoomMessage) {
RoomReceivedLuckyGiftAttachment attachment = (RoomReceivedLuckyGiftAttachment) chatRoomMessage.getAttachment();
if (messagesLuckyGift == null) messagesLuckyGift = new ArrayList<>();
messagesLuckyGift.add(transMessage(attachment.getLuckyBagNoticeInfo().getNick(), attachment.getLuckyBagNoticeInfo().getLuckyBagName(), attachment.getLuckyBagNoticeInfo().getGiftName()));
loopLuckyBagNotify();
}
private void loopLuckyBagNotify() {
if (disposableLuckyGift == null || messagesLuckyGift.size() == 1) {
isCreateLuckyGift = true;
disposableLuckyGift = Observable.interval(0, 6, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(aLong -> {
if (messagesLuckyGift.size() > 0 && !isCreateLuckyGift)
messagesLuckyGift.remove(0);//如果不是新创建的Observable发送的数据,需要移除第一个
isCreateLuckyGift = false;
})
.takeWhile(aLong -> messagesLuckyGift.size() > 0 && messagesLuckyGift.get(0) != null)
.subscribe(aLong -> showLuckyBagNotify(messagesLuckyGift.get(0)));
}
}
private SuperTextView transMessage(String nick, String luckyBagName, String giftName) {
SuperTextView textView = (SuperTextView) LayoutInflater.from(mContext).inflate(R.layout.layout_lucky_bag_notify_pic, null);
MessageView.SpannableBuilder text = new MessageView.SpannableBuilder(textView)
.append("哇偶! ", new ForegroundColorSpan(Color.WHITE))
.append(nick + " ", new ForegroundColorSpan(getResources().getColor(R.color.notice_nick)))
.append("通过", new ForegroundColorSpan(Color.WHITE))
.append(luckyBagName + " ", new ForegroundColorSpan(Color.WHITE))
.append("开出了", new ForegroundColorSpan(Color.WHITE))
.append(giftName, new ForegroundColorSpan(getResources().getColor(R.color.notice_gift)));
textView.setText(text.build());
return textView;
}
private void showLuckyBagNotify(SuperTextView textView) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.setMargins(0, 100, 0, 0);
textView.setLayoutParams(layoutParams);
if (animationLuckyGift == null)
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify);
gameMainBinding.flLuckygiftNotify.removeAllViews();
gameMainBinding.flLuckygiftNotify.setVisibility(View.VISIBLE);
gameMainBinding.flLuckygiftNotify.addView(textView);
gameMainBinding.flLuckygiftNotify.startAnimation(animationLuckyGift);
animationLuckyGift.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
gameMainBinding.flLuckygiftNotify.removeAllViews();
gameMainBinding.flLuckygiftNotify.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
@SuppressLint("CheckResult")
public void showKtvBox() {
GoldBoxHelper.isHideBox().subscribe(hide -> {

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -52,17 +52,16 @@
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_5"
android:drawablePadding="5dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:marqueeRepeatLimit="marquee_forever"
android:maxWidth="150dp"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="15sp"
tools:text="和你一起分享"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
/>
tools:text="和你一起分享" />
<ImageView
android:id="@+id/iv_high_audio"
@@ -104,16 +103,15 @@
android:layout_height="wrap_content"
android:textColor="@color/white_transparent_50"
android:textSize="@dimen/sp_9"
tools:text="8888"
/>
tools:text="8888" />
<com.yizhuan.erban.avroom.widget.FixRoomTitleTextView
android:id="@+id/room_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:textColor="@color/white_transparent_50"
android:textSize="9sp"
android:layout_marginStart="5dp"
tools:text="8888" />
@@ -125,19 +123,17 @@
android:id="@+id/tv_follow_room"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_23"
android:text="@string/collect"
android:textStyle="bold"
android:textSize="@dimen/sp_13"
android:textColor="@color/white"
android:layout_toEndOf="@+id/ll_room_info"
android:layout_marginStart="@dimen/dp_5"
android:gravity="center"
android:layout_marginTop="@dimen/dp_5"
android:layout_toEndOf="@+id/ll_room_info"
android:background="@drawable/bg_room_follow_room"
android:gravity="center"
android:paddingStart="@dimen/dp_10"
android:paddingEnd="@dimen/dp_10"
/>
android:text="@string/collect"
android:textColor="@color/white"
android:textSize="@dimen/sp_13"
android:textStyle="bold" />
<ImageView
@@ -149,8 +145,8 @@
android:layout_marginEnd="3dp"
android:layout_marginBottom="0dp"
android:paddingStart="7dp"
android:paddingEnd="10dp"
android:paddingTop="10dp"
android:paddingEnd="10dp"
android:paddingBottom="10dp"
android:scaleType="center"
android:src="@drawable/icon_room_more" />
@@ -163,8 +159,8 @@
android:layout_marginEnd="3dp"
android:layout_toStartOf="@id/room_more"
android:paddingStart="10dp"
android:paddingEnd="7dp"
android:paddingTop="10dp"
android:paddingEnd="7dp"
android:paddingBottom="10dp"
android:scaleType="center"
android:src="@drawable/ic_share_white" />
@@ -191,8 +187,8 @@
android:id="@+id/room_car_svga"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:scaleType="centerCrop"
android:visibility="gone"
app:autoPlay="true" />
<com.opensource.svgaplayer.SVGAImageView
@@ -214,14 +210,15 @@
android:layout_width="204dp"
android:layout_height="116dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="-12dp"
android:src="@drawable/room_cp_game_draw"
android:visibility="gone"
android:layout_marginTop="-12dp"/>
android:visibility="gone" />
<nl.dionsegijn.konfetti.KonfettiView
android:id="@+id/konfettiView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- 中奖横幅通知要在最上层 -->
<com.opensource.svgaplayer.SVGAImageView
@@ -232,19 +229,58 @@
app:autoPlay="true" />
<FrameLayout
android:id="@+id/fl_box_notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fl_lucky_gift_notify"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_5"
android:visibility="gone" />
android:layout_marginTop="50dp"
android:background="@drawable/bg_lucky_gift_notice"
android:visibility="gone" >
<TextView
android:id="@+id/tv_lucky_gift_notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="60dp"
android:paddingEnd="60dp"
android:textSize="12sp"
tools:text="" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_luckygift_notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fl_box_notify"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:visibility="gone" />
android:layout_marginTop="50dp"
android:background="@drawable/bg_box_notice"
android:visibility="gone">
<TextView
android:id="@+id/tv_box_notify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:paddingStart="60dp"
android:paddingEnd="60dp"
android:textSize="12sp"
tools:text="" />
</FrameLayout>
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/svga_box_notify"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="50dp"
android:visibility="gone"
app:autoPlay="true" />
<FrameLayout
android:id="@+id/fl_menber_in_notify"
@@ -254,7 +290,5 @@
android:layout_centerVertical="true"
android:visibility="gone" />
</RelativeLayout>
</layout>

View File

@@ -41,7 +41,7 @@
android:layout_width="0dp"
android:layout_height="@dimen/dp_30"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/dp_20"
android:layout_marginStart="@dimen/dp_15"
android:layout_weight="1"
android:background="@drawable/bg_home_search"
android:drawableStart="@mipmap/ic_home_search"

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center"
android:paddingLeft="@dimen/dp_60"
android:paddingRight="@dimen/dp_60"
android:layout_marginStart="@dimen/dp_6"
android:layout_marginEnd="@dimen/dp_6"
android:lines="2"
android:ellipsize="end"
android:paddingTop="@dimen/dp_5"
android:paddingBottom="@dimen/dp_5"
android:textSize="12sp"
tools:text=""
android:background="@drawable/bg_box_notice" />

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center"
android:paddingLeft="@dimen/dp_60"
android:paddingRight="@dimen/dp_60"
android:layout_marginStart="@dimen/dp_6"
android:layout_marginEnd="@dimen/dp_6"
android:lines="2"
android:ellipsize="end"
android:paddingTop="@dimen/dp_5"
android:paddingBottom="@dimen/dp_5"
android:textSize="12sp"
tools:text=""
android:background="@drawable/bg_lucky_gift_notice" />

View File

@@ -231,6 +231,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_QUEUING_MIC;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_IN_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_ADD;
@@ -312,40 +313,39 @@ public final class IMNetEaseManager {
/**
* 注册消息过滤器
*
*/
private void registerMessageFilter() {
NIMClient.getService(MsgService.class)
.registerIMMessageFilter(message -> {
if (message.getMsgType() == MsgTypeEnum.custom) {
CustomAttachment customAttachment = (CustomAttachment) message.getAttachment();
if (customAttachment != null){
switch (customAttachment.getFirst()) {
case CustomAttachment.CUSTOM_MSG_HEADER_TYPE_LUCKY_MONEY:
switch (customAttachment.getSecond()) {
case CustomAttachment.CUSTOM_MSG_SUB_TYPE_RECEIVE_LUCKY_MONEY:
LuckyMoneyTipsAttachment luckyMoneyAttachment = (LuckyMoneyTipsAttachment) message.getAttachment();
LuckyMoneyInfo luckyMoneyInfo = luckyMoneyAttachment.getLuckyMoneyInfo();
String uid = String.valueOf(AuthModel.get().getCurrentUid());
// 你领取了某人的红包 || 某人领取了你的红包
if (!(Objects.equals(uid, String.valueOf(luckyMoneyInfo.getReceiveUid())) ||
Objects.equals(uid, String.valueOf(luckyMoneyInfo.getSenderUid())))) {
Log.e(TAG, "registerMessageFilter: CUSTOM_MSG_SUB_TYPE_RECEIVE_LUCKY_MONEY");
return true;
}
break;
}
break;
if (customAttachment != null) {
switch (customAttachment.getFirst()) {
case CustomAttachment.CUSTOM_MSG_HEADER_TYPE_LUCKY_MONEY:
switch (customAttachment.getSecond()) {
case CustomAttachment.CUSTOM_MSG_SUB_TYPE_RECEIVE_LUCKY_MONEY:
LuckyMoneyTipsAttachment luckyMoneyAttachment = (LuckyMoneyTipsAttachment) message.getAttachment();
LuckyMoneyInfo luckyMoneyInfo = luckyMoneyAttachment.getLuckyMoneyInfo();
String uid = String.valueOf(AuthModel.get().getCurrentUid());
// 你领取了某人的红包 || 某人领取了你的红包
if (!(Objects.equals(uid, String.valueOf(luckyMoneyInfo.getReceiveUid())) ||
Objects.equals(uid, String.valueOf(luckyMoneyInfo.getSenderUid())))) {
Log.e(TAG, "registerMessageFilter: CUSTOM_MSG_SUB_TYPE_RECEIVE_LUCKY_MONEY");
return true;
}
break;
}
break;
//邀请粉丝
case CustomAttachment.CUSTOM_MSG_PUSH_NOTIFIFICATION:
switch (customAttachment.getSecond()){
case CustomAttachment.CUSTOM_MSG_SUB_PUSH_NOTIFICATION_IN_ROOM:
Log.e(TAG, "registerMessageFilter: CUSTOM_MSG_PUSH_NOTIFIFICATION");
return true;
}
break;
}
//邀请粉丝
case CustomAttachment.CUSTOM_MSG_PUSH_NOTIFIFICATION:
switch (customAttachment.getSecond()) {
case CustomAttachment.CUSTOM_MSG_SUB_PUSH_NOTIFICATION_IN_ROOM:
Log.e(TAG, "registerMessageFilter: CUSTOM_MSG_PUSH_NOTIFIFICATION");
return true;
}
break;
}
}
} else if (message.getMsgType() == MsgTypeEnum.notification) {
NotificationAttachment notificationAttachment = (NotificationAttachment) message.getAttachment();
@@ -421,7 +421,7 @@ public final class IMNetEaseManager {
}
public Map<String, Object> toMap(Map<String, Object> map, String namePlateWord,String namePlatePic) {
public Map<String, Object> toMap(Map<String, Object> map, String namePlateWord, String namePlatePic) {
if (map == null) {
map = new HashMap<>();
}
@@ -467,7 +467,7 @@ public final class IMNetEaseManager {
valueMap = headWearInfo.toMap(valueMap);
}
valueMap = toMap(valueMap,userInfo.getNameplateWord(),userInfo.getNameplatePic());
valueMap = toMap(valueMap, userInfo.getNameplateWord(), userInfo.getNameplatePic());
if (valueMap != null && valueMap.size() > 0) {
map.put(String.valueOf(userInfo.getUid()), valueMap);
@@ -670,7 +670,7 @@ public final class IMNetEaseManager {
if (ListUtils.isListEmpty(targets)) {
return;
}
chatRoomMemberIn(targets.get(0),msg);
chatRoomMemberIn(targets.get(0), msg);
//如果是自己进房,立即刷新一次超管缓存
if (UserModel.get().isMyseft(targets.get(0))) {
SuperAdminDataMrg.get().firstInitList();
@@ -817,7 +817,7 @@ public final class IMNetEaseManager {
face = true;
break;
case CUSTOM_MSG_HEADER_TYPE_GIFT:
if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_GIFT){
if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_GIFT) {
GiftAttachment giftAttachment = (GiftAttachment) attachment;
GiftInfo giftInfo = giftAttachment.getGiftReceiveInfo().getGift();
// 兼容旧版发过来的giftAttachment没有发送giftInfo的问题
@@ -827,7 +827,7 @@ public final class IMNetEaseManager {
GiftModel.get().addNewGift(giftInfo);
messages.add(msg);
gift = true;
}else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT){
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT) {
MultiLuckyGiftAttachment luckyGiftAttachment = (MultiLuckyGiftAttachment) attachment;
GiftModel.get().addNewGift(luckyGiftAttachment.getMultiLuckyGiftReceiveInfo().getDisplayGift().get(0));
messages.add(msg);
@@ -850,12 +850,12 @@ public final class IMNetEaseManager {
GiftModel.get().addNewGift(giftBatchAttachment.getGiftMultiReceiverInfo().getGift());
messages.add(msg);
gift = true;
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ALL_MIC_LUCKY_GIFT){
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ALL_MIC_LUCKY_GIFT) {
MultiLuckyGiftAttachment luckyGiftAttachment = (MultiLuckyGiftAttachment) attachment;
GiftModel.get().addNewGift(luckyGiftAttachment.getMultiLuckyGiftReceiveInfo().getDisplayGift().get(0));
messages.add(msg);
gift = true;
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_MULTI_LUCK_GIFT){
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_MULTI_LUCK_GIFT) {
MultiLuckyGiftAttachment luckyGiftAttachment = (MultiLuckyGiftAttachment) attachment;
GiftModel.get().addNewGift(luckyGiftAttachment.getMultiLuckyGiftReceiveInfo().getDisplayGift().get(0));
messages.add(msg);
@@ -985,6 +985,7 @@ public final class IMNetEaseManager {
}
break;
case CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY:
case CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA:
if (AvRoomDataManager.get().isOpenPureMode()) {
// 纯净模式打开后,仅能看跟自己相关的砸蛋消息
RoomBoxPrizeAttachment roomBoxPrizeAttachment = (RoomBoxPrizeAttachment) msg.getAttachment();
@@ -993,7 +994,7 @@ public final class IMNetEaseManager {
}
} else {
addMessages(msg);
noticeBox(msg);
noticeBox(msg, second);
}
break;
}
@@ -1265,7 +1266,7 @@ public final class IMNetEaseManager {
break;
case CustomAttachment.CUSTOM_MSG_LEVEL_UP:
switch (second){
switch (second) {
case CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE:
noticeExperLevelUpNotice(msg);
break;
@@ -1433,7 +1434,7 @@ public final class IMNetEaseManager {
chatRoomMember.setAvatar((String) extensionDataMap.get("avatar"));
}
int experLevelSeq = 0;
int experLevelSeq = 0;
if (extensionDataMap.containsKey("experLevelSeq")) {
experLevelSeq = (int) extensionDataMap.get("experLevelSeq");
}
@@ -1726,7 +1727,6 @@ public final class IMNetEaseManager {
}
/**
* 添加消息到公屏
*
@@ -1758,7 +1758,7 @@ public final class IMNetEaseManager {
noticeReceiverMessage(msg);
}
public void addOpenRedPackageSwitch(ChatRoomMessage msg){
public void addOpenRedPackageSwitch(ChatRoomMessage msg) {
noticeReceiverMessage(msg);
}
@@ -2597,7 +2597,6 @@ public final class IMNetEaseManager {
}
/************************云信聊天室 房主/管理员操作 end******************************/
/**
@@ -3119,7 +3118,7 @@ public final class IMNetEaseManager {
/**
* 更新系统消息到本地数据库
*
* @param uuid 消息 UUID
* @param uuid 消息 UUID
* @param sysMsgV2Info 系统消息实体
*/
public void updateErbanSysMsgV2InfoMessage(String uuid, ErbanSysMsgV2Info sysMsgV2Info) {
@@ -3345,10 +3344,11 @@ public final class IMNetEaseManager {
.setChatRoomMessage(msg));
}
private void noticeBox(ChatRoomMessage msg) {
private void noticeBox(ChatRoomMessage msg, int second) {
int event = second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY ? RoomEvent.BOX_NOTIFY : RoomEvent.BOX_NOTIFY_SVGA;
getChatRoomEventObservable()
.onNext(new RoomEvent()
.setEvent(RoomEvent.BOX_NOTIFY)
.setEvent(event)
.setChatRoomMessage(msg));
}

View File

@@ -156,6 +156,7 @@ public class CustomAttachment implements MsgAttachment {
public static final int CUSTOM_MSG_SUB_BOX_IN_ROOM = 262;//当前房间可见
public static final int CUSTOM_MSG_SUB_BOX_ALL_ROOM = 263;//所有房间可见
public static final int CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY = 264;//所有房间可见+小秘书
public static final int CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA = 265;//所有房间可见+小秘书+高大上的SVGA
//KTV
public static final int CUSTOM_MSG_KTV = 27;

View File

@@ -203,6 +203,9 @@ public class RoomEvent {
/** */
public static final int RECEIVE_EXPER_LEVEL_UP_NOTICE = 68;
//开宝箱横幅,SVGA背景的
public static final int BOX_NOTIFY_SVGA = 69;
private int event = NONE;
private int micPosition = Integer.MIN_VALUE;
private int posState = -1;