修复 全服飘窗

This commit is contained in:
wzq
2023-09-20 14:55:52 +08:00
parent a5094d6ead
commit d5b8ee1737
7 changed files with 217 additions and 14 deletions

View File

@@ -161,6 +161,11 @@ public class XChatApplication extends BaseApp {
public String makeRevokeMsgTip(String s, IMMessage imMessage) {
return null;
}
@Override
public String makeCategory(IMMessage message) {
return null;
}
};
private static XChatApplication instance;
//生命周期监听

View File

@@ -12,6 +12,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_LUCKY_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
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_DRAW_GIFT_L5;
@@ -34,6 +35,7 @@ import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -100,9 +102,12 @@ import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.UriProvider;
import com.yizhuan.xchat_android_core.bean.BaseProtocol;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Attachment;
import com.yizhuan.xchat_android_core.im.custom.bean.PlayEffectInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
import com.yizhuan.xchat_android_core.manager.RoomEvent;
@@ -192,7 +197,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
if (roomEvent == null) return;
onReceiveChatRoomEvent(roomEvent);
}));
registerNimBroadcastMessage(true);
}
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
@@ -207,6 +211,7 @@ public abstract class BaseActivity extends RxAppCompatActivity
if (broadcastObserver == null) {
broadcastObserver = new BroadcastObserver(this);
}
Log.d("fuck", "registerNimBroadcastMessage: " + register + this);
NIMSDK.getMsgServiceObserve().observeBroadcastMessage(broadcastObserver, register);
}
@@ -362,16 +367,17 @@ public abstract class BaseActivity extends RxAppCompatActivity
@Override
protected void onStart() {
super.onStart();
registerNimBroadcastMessage(true);
}
@Override
protected void onStop() {
super.onStop();
registerNimBroadcastMessage(false);
}
@Override
protected void onDestroy() {
registerNimBroadcastMessage(false);
if (mCompositeDisposable != null) {
mCompositeDisposable.dispose();
mCompositeDisposable = null;
@@ -1022,6 +1028,65 @@ public abstract class BaseActivity extends RxAppCompatActivity
}
}
break;
case CustomAttachment.CUSTOM_MESS_TAROT:
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) {
TarotMsgBean tarotMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), TarotMsgBean.class);
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING);
playEffectInfo.setTarotMsgBean(tarotMsgBean);
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5:
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE) {
NotifyH5Attachment.Bean bean = JSON.parseObject(String.valueOf(baseProtocol.getData()), NotifyH5Attachment.Bean.class);
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE);
playEffectInfo.setNotifyH5(bean);
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CUSTOM_MSG_LUCKY_SEA://星级厨房
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity

View File

@@ -10,6 +10,7 @@ import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.Layout;
import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
@@ -23,7 +24,11 @@ import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.text.HtmlCompat;
import com.alibaba.fastjson.JSON;
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGADynamicEntity;
import com.opensource.svgaplayer.SVGAImageView;
@@ -34,8 +39,16 @@ import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.common.svga.SimpleSvgaCallback;
import com.yizhuan.erban.databinding.DialogAllPlayEffectBinding;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.erban.utils.SpannableBuilder;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Attachment;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
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.treasurefairy.FairyMsgInfoBean;
import com.yizhuan.xchat_android_core.im.custom.bean.PlayEffectInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
@@ -43,6 +56,8 @@ import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.StringUtils;
import lombok.val;
public class AllPlayEffectDialog extends BaseDialog {
private final PlayEffectInfo playEffectInfo;
@@ -74,14 +89,27 @@ public class AllPlayEffectDialog extends BaseDialog {
window.setAttributes(windowParams);
window.setWindowAnimations(R.style.anim_left);
}
if (playEffectInfo.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
showBoxNotifyBySVGA(playEffectInfo.getRoomBoxPrizeInfo());
} else if (playEffectInfo.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
showLuckySeaNotifyBySVGA(playEffectInfo.getRoomLuckySeaMsgBean());
} else if (playEffectInfo.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
showLuckyBagNotify(playEffectInfo.getLuckyBagNoticeInfo());
} else if(playEffectInfo.getSecond() == CUSTOM_MSG_SUB_DRAW_GIFT_L5){
showFairyNotifyBySVGA(playEffectInfo.getFairyMsgInfo());
switch (playEffectInfo.getSecond()) {
case CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA:
showBoxNotifyBySVGA(playEffectInfo.getRoomBoxPrizeInfo());
break;
case CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL:
showLuckySeaNotifyBySVGA(playEffectInfo.getRoomLuckySeaMsgBean());
break;
case CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL:
showLuckyBagNotify(playEffectInfo.getLuckyBagNoticeInfo());
break;
case CUSTOM_MSG_SUB_DRAW_GIFT_L5:
showFairyNotifyBySVGA(playEffectInfo.getFairyMsgInfo());
break;
case CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING:
showTarotNotifyBySvga(playEffectInfo.getTarotMsgBean());
break;
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE:
showNotifyH5BySvga(playEffectInfo.getNotifyH5());
break;
default:
break;
}
}
@@ -330,6 +358,107 @@ public class AllPlayEffectDialog extends BaseDialog {
}
}
private void showNotifyH5BySvga(NotifyH5Attachment.Bean info) {
SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1);
svgaImageView.setClearsAfterDetached(true);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
svgaImageView.setLayoutParams(params);
svgaImageView.setCallback(new SimpleSvgaCallback() {
@Override
public void onFinished() {
closeSelf();
}
});
binding.flSvgaNotify.addView(svgaImageView);
try {
SVGAParser.Companion.shareParser().decodeFromAssets("svga/svga_notify_h5.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色
textPaint.setTextSize(24);//字体大小
dynamicEntity.setDynamicText(new StaticLayout(
info.getContent(),
0,
info.getContent().length(),
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "bg");
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
svgaImageView.setImageDrawable(drawable);
svgaImageView.stepToFrame(0, true);
}
@Override
public void onError() {
closeSelf();
}
}, null);
} catch (Exception e) {
e.printStackTrace();
closeSelf();
}
}
private void showTarotNotifyBySvga(TarotMsgBean tarotMsgBean) {
String string = getContext().getString(
R.string.avroom_widget_roomeffectview_026,
StringUtils.abbreviate(RegexUtil.getPrintableString(tarotMsgBean.getNick()), 8),
tarotMsgBean.getDrawGoldNum());
Spanned spanned = HtmlCompat.fromHtml(string, HtmlCompat.FROM_HTML_MODE_COMPACT);
SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1);
svgaImageView.setClearsAfterDetached(true);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
svgaImageView.setLayoutParams(params);
svgaImageView.setCallback(new SimpleSvgaCallback() {
@Override
public void onFinished() {
closeSelf();
}
});
binding.flSvgaNotify.addView(svgaImageView);
try {
SVGAParser.Companion.shareParser().decodeFromAssets("svga/svga_tarot_senior.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色
textPaint.setTextSize(24);//字体大小
dynamicEntity.setDynamicText(new StaticLayout(
spanned,
0,
spanned.length(),
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "taxt");
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
svgaImageView.setImageDrawable(drawable);
svgaImageView.stepToFrame(0, true);
}
@Override
public void onError() {
closeSelf();
}
}, null);
} catch (Exception e) {
e.printStackTrace();
closeSelf();
}
}
private void showFairyNotifyBySVGA(FairyMsgInfoBean fairyMsgInfo) {
SpannableBuilder text = new SpannableBuilder()
.append("好運爆棚!", new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_8C4700)))

View File

@@ -461,12 +461,12 @@ public class CustomAttachment implements MsgAttachment {
/**
* H5活动通用飘屏 - 房间
*/
public static final int CUSTOM_MSG_NOTIFY_H5_SUB_ROOM = 1001;
public static final int CUSTOM_MSG_NOTIFY_H5_SUB_ROOM = 1101;
/**
* H5活动通用飘屏 - 全服
*/
public static final int CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE = 1002;
public static final int CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE = 1102;
/**
* 自定义消息附件的类型,根据该字段区分不同的自定义消息

View File

@@ -7,9 +7,14 @@ import lombok.Data;
@Data
public class PlayEffectInfo {
private int second;
private RoomBoxPrizeInfo roomBoxPrizeInfo;
private RoomLuckySeaMsgBean roomLuckySeaMsgBean;
private LuckyBagNoticeInfo luckyBagNoticeInfo;
private FairyMsgInfoBean fairyMsgInfo;
private TarotMsgBean tarotMsgBean;
private NotifyH5Attachment.Bean notifyH5;
}

View File

@@ -8,7 +8,6 @@ import com.netease.nimlib.sdk.NIMSDK;
import com.netease.nimlib.sdk.Observer;
import com.netease.nimlib.sdk.msg.model.BroadcastMessage;
import com.yizhuan.xchat_android_core.bean.BaseProtocol;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.upgrade.bean.NewestVersionInfo;
import com.yizhuan.xchat_android_core.upgrade.event.ImPushUpdateAppEvent;

View File

@@ -47,7 +47,7 @@ def overscroll_android = "1.0.4"
def base_recyclerview_helper = "2.9.49-androidx"
def ShortcutBadger = "1.1.17"
def GlideTransformationsVersion = "3.0.1"
def NimNetVersion = "8.9.103"
def NimNetVersion = "8.9.118"
def glideVersion = "4.11.0"
dependencies {