Java Code Examples for io.rong.imlib.model.Message#getContent()

The following examples show how to use io.rong.imlib.model.Message#getContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SessionAdapter.java    From LQRWeChat with MIT License 5 votes vote down vote up
@Override
public void convert(LQRViewHolderForRecyclerView helper, Message item, int position) {
    setTime(helper, item, position);
    setView(helper, item, position);
    if (!(item.getContent() instanceof GroupNotificationMessage) && !(item.getContent() instanceof RecallNotificationMessage) && (getItemViewType(position) != UNDEFINE_MSG)) {
        setAvatar(helper, item, position);
        setName(helper, item, position);
        setStatus(helper, item, position);
        setOnClick(helper, item, position);
    }
}
 
Example 2
Source File: SessionAdapter.java    From LQRWeChat with MIT License 5 votes vote down vote up
@Override
public int getItemViewType(int position) {
    Message msg = mData.get(position);
    boolean isSend = msg.getMessageDirection() == Message.MessageDirection.SEND ? true : false;

    MessageContent msgContent = msg.getContent();
    if (msgContent instanceof TextMessage) {
        return isSend ? SEND_TEXT : RECEIVE_TEXT;
    }
    if (msgContent instanceof ImageMessage) {
        return isSend ? SEND_IMAGE : RECEIVE_IMAGE;
    }
    if (msgContent instanceof FileMessage) {
        FileMessage fileMessage = (FileMessage) msgContent;
        if (MediaFileUtils.isImageFileType(fileMessage.getName())) {
            return isSend ? SEND_STICKER : RECEIVE_STICKER;
        } else if (MediaFileUtils.isVideoFileType(fileMessage.getName())) {
            return isSend ? SEND_VIDEO : RECEIVE_VIDEO;
        }
    }
    if (msgContent instanceof LocationMessage) {
        return isSend ? SEND_LOCATION : RECEIVE_LOCATION;
    }
    if (msgContent instanceof GroupNotificationMessage) {
        return RECEIVE_NOTIFICATION;
    }
    if (msgContent instanceof VoiceMessage) {
        return isSend ? SEND_VOICE : RECEIVE_VOICE;
    }
    if (msgContent instanceof RedPacketMessage) {
        return isSend ? SEND_RED_PACKET : RECEIVE_RED_PACKET;
    }
    if (msgContent instanceof RecallNotificationMessage) {
        return RECALL_NOTIFICATION;
    }
    return UNDEFINE_MSG;
}
 
Example 3
Source File: SealAppContext.java    From sealtalk-android with MIT License 4 votes vote down vote up
@Override
    public boolean onReceived(Message message, int i) {
        MessageContent messageContent = message.getContent();
        if (messageContent instanceof ContactNotificationMessage) {
            ContactNotificationMessage contactNotificationMessage = (ContactNotificationMessage) messageContent;
            if (contactNotificationMessage.getOperation().equals("Request")) {
                //对方发来好友邀请
                BroadcastManager.getInstance(mContext).sendBroadcast(SealAppContext.UPDATEREDDOT);
            } else if (contactNotificationMessage.getOperation().equals("AcceptResponse")) {
                //对方同意我的好友请求
                ContactNotificationMessageData c = null;
                try {
                    c = JsonMananger.jsonToBean(contactNotificationMessage.getExtra(), ContactNotificationMessageData.class);
                } catch (HttpException e) {
                    e.printStackTrace();
                }
                if (c != null) {
                    DBManager.getInstance(mContext).getDaoSession().getFriendDao().insertOrReplace(new Friend(contactNotificationMessage.getSourceUserId(), c.getSourceUserNickname(), null, null, null, null));
                }
                BroadcastManager.getInstance(mContext).sendBroadcast(UPDATEFRIEND);
                BroadcastManager.getInstance(mContext).sendBroadcast(SealAppContext.UPDATEREDDOT);
            }
//                // 发广播通知更新好友列表
//            BroadcastManager.getInstance(mContext).sendBroadcast(UPDATEREDDOT);
//            }
        } else if (messageContent instanceof AgreedFriendRequestMessage) {//好友添加成功消息
            AgreedFriendRequestMessage agreedFriendRequestMessage = (AgreedFriendRequestMessage) messageContent;
            if (agreedFriendRequestMessage.getUserInfo() != null) {
                UserInfo bean = agreedFriendRequestMessage.getUserInfo();
                DBManager.getInstance(mContext).getDaoSession().getFriendDao().insertOrReplace(
                        new Friend(bean.getUserId(), bean.getName(), String.valueOf(bean.getPortraitUri()), null, null, null)
                );
            } else {
                DBManager.getInstance(mContext).getDaoSession().getFriendDao().insertOrReplace(
                        new Friend(agreedFriendRequestMessage.getFriendId())
                );
                RongIM.getInstance().refreshUserInfoCache(new UserInfo(agreedFriendRequestMessage.getUserInfo().getUserId(),
                        agreedFriendRequestMessage.getUserInfo().getName(),
                        agreedFriendRequestMessage.getUserInfo().getPortraitUri()
                ));
            }
        } else if (messageContent instanceof GroupNotificationMessage) {
            GroupNotificationMessage groupNotificationMessage = (GroupNotificationMessage) messageContent;
            NLog.e("" + groupNotificationMessage.getMessage());
            if (groupNotificationMessage.getOperation().equals("Kicked")) {
            } else if (groupNotificationMessage.getOperation().equals("Add")) {
            } else if (groupNotificationMessage.getOperation().equals("Quit")) {
            } else if (groupNotificationMessage.getOperation().equals("Rename")) {
            }

            BroadcastManager.getInstance(mContext).sendBroadcast(SealAppContext.NETUPDATEGROUP);
        } else if (messageContent instanceof ImageMessage) {
            ImageMessage imageMessage = (ImageMessage) messageContent;
            Log.e("imageMessage", imageMessage.getRemoteUri().toString());
        }
        return false;
    }