fix:修复通用公屏异常(FastJson解析DataClass问题)
feat:增加trycatch避免直接崩溃
This commit is contained in:
@@ -1461,21 +1461,25 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
String contentStr = broadcastMessage.getContent();
|
||||
Logger.i(ResUtil.getString(R.string.avroom_activity_avroomactivity_014) + contentStr);
|
||||
if (TextUtils.isEmpty(contentStr)) return;
|
||||
AVRoomActivity activity = mReference.get();
|
||||
if (activity == null) return;
|
||||
if (activity.isValid()) {
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
try {
|
||||
AVRoomActivity activity = mReference.get();
|
||||
if (activity == null) return;
|
||||
if (activity.isValid()) {
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1503,14 +1503,15 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -73,29 +73,29 @@ open class TemplateMessage : Serializable {
|
||||
return list
|
||||
}
|
||||
|
||||
data class Content(
|
||||
/**
|
||||
* 公共字段
|
||||
*/
|
||||
val key: String? = null,
|
||||
// TEXT,IMAGE
|
||||
val type: String? = null,
|
||||
val skipType: Int? = null,
|
||||
val skipContent: String? = null,
|
||||
class Content : Serializable, IRouterData {
|
||||
/**
|
||||
* 公共字段
|
||||
*/
|
||||
val key: String? = null
|
||||
|
||||
/**
|
||||
* 文本相关字段(type=TEXT)
|
||||
*/
|
||||
val text: I18N? = null,
|
||||
var textColor: String? = null,
|
||||
// TEXT,IMAGE
|
||||
val type: String? = null
|
||||
val skipType: Int? = null
|
||||
val skipContent: String? = null
|
||||
|
||||
/**
|
||||
* 图片相关字段(type=IMAGE)
|
||||
*/
|
||||
val image: String? = null,
|
||||
val width: Int? = null,
|
||||
val height: Int? = null
|
||||
) : Serializable, IRouterData {
|
||||
/**
|
||||
* 文本相关字段(type=TEXT)
|
||||
*/
|
||||
val text: I18N? = null
|
||||
var textColor: String? = null
|
||||
|
||||
/**
|
||||
* 图片相关字段(type=IMAGE)
|
||||
*/
|
||||
val image: String? = null
|
||||
val width: Int? = null
|
||||
val height: Int? = null
|
||||
|
||||
override fun getSkipType(): Int {
|
||||
return skipType ?: 0
|
||||
|
Reference in New Issue
Block a user