diff --git a/app/src/main/java/com/chwl/app/avroom/public_chat/PublicChatMessageView.java b/app/src/main/java/com/chwl/app/avroom/public_chat/PublicChatMessageView.java index 5006bc39c..d9924005b 100644 --- a/app/src/main/java/com/chwl/app/avroom/public_chat/PublicChatMessageView.java +++ b/app/src/main/java/com/chwl/app/avroom/public_chat/PublicChatMessageView.java @@ -89,6 +89,7 @@ import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage; import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension; import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment; import com.netease.nimlib.sdk.msg.attachment.ImageAttachment; +import com.netease.nimlib.sdk.msg.attachment.MsgAttachment; import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum; import com.netease.nimlib.sdk.msg.constant.NotificationType; @@ -545,16 +546,20 @@ public class PublicChatMessageView extends FrameLayout { setMsgNotification(chatRoomMessage, tvContent, baseViewHolder.getAdapterPosition()); setVIPMessageBackground(chatRoomMessage, tvContent); } else if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) { - CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment(); - int first = attachment.getFirst(); - int second = attachment.getSecond(); - if (first == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED) { - if (second == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) { - setHeadlineMsg(chatRoomMessage, tvContent, attachment); + if (chatRoomMessage.getAttachment() != null && chatRoomMessage.getAttachment() instanceof CustomAttachment) { + CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment(); + int first = attachment.getFirst(); + int second = attachment.getSecond(); + if (first == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED) { + if (second == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) { + setHeadlineMsg(chatRoomMessage, tvContent, attachment); + } + } else { + tvContent.setTextColor(Color.WHITE); + tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip)); } } else { - tvContent.setTextColor(Color.WHITE); - tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip)); + tvContent.setText(""); } } } catch (UnsupportedOperationException e) { @@ -562,6 +567,9 @@ public class PublicChatMessageView extends FrameLayout { clearBackground(tvContent); tvContent.setTextColor(Color.WHITE); tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip)); + } catch (Exception e) { + clearBackground(tvContent); + tvContent.setText(""); } }