fix:修复通用模版消息解析json问题
This commit is contained in:
@@ -48,6 +48,7 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
@@ -1302,7 +1303,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
case CUSTOM_MSG_TEMPLATE_NOTIFY://通用飘屏
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
RoomTemplateNotifyAttachment attachment = new RoomTemplateNotifyAttachment(CUSTOM_MSG_TEMPLATE_NOTIFY, CUSTOM_MSG_TEMPLATE_NOTIFY_ALL);
|
||||
attachment.setMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class));
|
||||
attachment.setMsgBean(new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.TEMPLATE_NOTIFY);
|
||||
}
|
||||
|
@@ -1162,9 +1162,9 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
RoomTemplateNotifyMsgBean templateNotifyMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class);
|
||||
if (templateNotifyMsgBean == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
RoomTemplateNotifyMsgBean templateNotifyMsgBean = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class);
|
||||
if (templateNotifyMsgBean == null) return;
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(baseProtocol.getSecond());
|
||||
playEffectInfo.setTemplateNotifyMsgBean(templateNotifyMsgBean);
|
||||
|
@@ -6,7 +6,9 @@ import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.text.SpannableString
|
||||
import android.view.View
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.chuhai.utils.log.ILog
|
||||
import com.google.gson.Gson
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
import com.tongdaxing.erban.upgrade.AppUpgradeHelper
|
||||
import com.yizhuan.erban.BuildConfig
|
||||
@@ -16,7 +18,6 @@ import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager.OkCancelDialogListener
|
||||
import com.yizhuan.erban.databinding.ActivitySettingBinding
|
||||
import com.yizhuan.erban.ui.im.avtivity.BlackListManageActivity
|
||||
import com.yizhuan.erban.ui.invite.InviteImageHelper
|
||||
import com.yizhuan.erban.ui.invite.ShareInviteDialog
|
||||
import com.yizhuan.erban.ui.invite.ShareInviteInfo
|
||||
import com.yizhuan.erban.ui.login.BindPhoneActivity
|
||||
@@ -27,6 +28,7 @@ import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.auth.event.LogoutEvent
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTemplateNotifyMsgBean
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.utils.SharedPreferenceUtils
|
||||
@@ -221,6 +223,7 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
}
|
||||
|
||||
private fun debug() {
|
||||
test()
|
||||
// CommonWebViewActivity.start(
|
||||
// this,
|
||||
// "http://192.168.19.136:5502/view/peko/activity/2024-invitationFission/share.html"
|
||||
@@ -237,7 +240,7 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
toUrl = "https://www.baidu.com",
|
||||
)
|
||||
// InviteImageHelper().saveToAlbum(this, rxPermissions, data)
|
||||
ShareInviteDialog(data).show(supportFragmentManager, "A")
|
||||
// ShareInviteDialog(data).show(supportFragmentManager, "A")
|
||||
// val json = "{\"data\":{\"diamonds\":225000,\"itemId\":32,\"itemMultiple\":45,\"nick\":\"XG001\",\"roomUid\":2881,\"uid\":2881},\"first\":95,\"second\":955}"
|
||||
// RedPackageOpenDialog2().show(this)
|
||||
// val json = "{\"first\":85,\"second\":855,\"data\":{\"nick\":\"66丢丢丢丢丢多多多的hhhh\",\"preVipName\":\"子爵\",\"floatPic\":\"https://image.hfighting.com/Fq3JtbK2acO3FN-3vWZo8ldtHfse\",\"uid\":2735,\"currVipName\":\"侯爵\",\"erbanNo\":66,\"roomUid\":2734,\"avatar\":\"https://img.pekolive.com/default_avatar.png\",\"currVipLevel\":5}}"
|
||||
@@ -245,4 +248,29 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
|
||||
// CommonWebViewActivity.start(this,"https://api.anan.chat/anan_vestBag/modules/rank/index.html#/rank")
|
||||
// CommonWebViewActivity.start(this,"https://api.anan.chat/anan_vestBag/modules/myincome/index.html#/DiamondLog")
|
||||
}
|
||||
|
||||
private fun test(){
|
||||
logD("test()")
|
||||
val json = "{\"fontSize\":12,\"resourceType\":\"IMAGE\",\"resourceContent\":\"https://piko-1320554189.cos.ap-singapore.myqcloud.com/gYWPkyh3s6FG1Cc4lfKowGUgyTYDaNPBYwXfcy79fnA2i1U4LFJJR.png\",\"resourceWidth\":750,\"resourceHeight\":121,\"svgaTextKey\":\"noble_text_tx\",\"template\":{\"zh-CN\":\"恭喜{senderNick}赠送{giftName},爆出{outputValue}钻石大奖!\"},\"textColor\":\"#FFFFFF\",\"contents\":[{\"text\":{\"zh-CN\":\"[2813]\"},\"fontSize\":12,\"textColor\":\"#FFFF00\",\"type\":\"TEXT\",\"key\":\"senderNick\"},{\"text\":{\"zh-CN\":\"[守護之星]\"},\"fontSize\":12,\"textColor\":\"#FFFF00\",\"type\":\"TEXT\",\"key\":\"giftName\"},{\"text\":{\"zh-CN\":\"597\"},\"fontSize\":12,\"textColor\":\"#FFFF00\",\"type\":\"TEXT\",\"key\":\"outputValue\"}]}"
|
||||
try {
|
||||
val data = JSON.parseObject(json, RoomTemplateNotifyMsgBean::class.java)
|
||||
logD("data:${data}")
|
||||
logD("data0:${data.contents?.size}")
|
||||
logD("data1:${data.contents?.firstOrNull()?.key}")
|
||||
logD("data2:${data.contents?.firstOrNull()?.text}")
|
||||
}catch (e:Exception){
|
||||
logD("test() error")
|
||||
e.printStackTrace()
|
||||
}
|
||||
try {
|
||||
val data2 = Gson().fromJson<RoomTemplateNotifyMsgBean>(json, RoomTemplateNotifyMsgBean::class.java)
|
||||
logD("data:${data2}")
|
||||
logD("data0:${data2.contents?.size}")
|
||||
logD("data1:${data2.contents?.firstOrNull()?.key}")
|
||||
logD("data2:${data2.contents?.firstOrNull()?.text}")
|
||||
}catch (e:Exception){
|
||||
logD("test() error2")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
@@ -34,6 +34,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
@@ -513,7 +514,7 @@ public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBox
|
||||
case CUSTOM_MSG_TEMPLATE_NOTIFY://通用飘屏
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
RoomTemplateNotifyAttachment attachment = new RoomTemplateNotifyAttachment(CUSTOM_MSG_TEMPLATE_NOTIFY, CUSTOM_MSG_TEMPLATE_NOTIFY_ALL);
|
||||
attachment.setMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class));
|
||||
attachment.setMsgBean(new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.TEMPLATE_NOTIFY);
|
||||
}
|
||||
|
Reference in New Issue
Block a user