io.rong.message.ImageMessage Java Examples

The following examples show how to use io.rong.message.ImageMessage. 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
private void setOnClick(LQRViewHolderForRecyclerView helper, Message item, int position) {
    helper.getView(R.id.llError).setOnClickListener(v ->
            RongIMClient.getInstance().deleteMessages(new int[]{item.getMessageId()}, new RongIMClient.ResultCallback<Boolean>() {
                @Override
                public void onSuccess(Boolean aBoolean) {
                    mData.remove(position);
                    mPresenter.setAdapter();
                    MessageContent content = item.getContent();
                    if (content instanceof TextMessage) {
                        mPresenter.sendTextMsg(((TextMessage) content).getContent());
                    } else if (content instanceof ImageMessage) {
                        mPresenter.sendImgMsg(((ImageMessage) content).getThumUri(), ((ImageMessage) content).getLocalUri());
                    } else if (content instanceof FileMessage) {
                        mPresenter.sendFileMsg(new File(((FileMessage) content).getLocalPath().getPath()));
                    } else if (content instanceof VoiceMessage) {
                        VoiceMessage voiceMessage = (VoiceMessage) content;
                        mPresenter.sendAudioFile(voiceMessage.getUri(), voiceMessage.getDuration());
                    }
                }

                @Override
                public void onError(RongIMClient.ErrorCode errorCode) {

                }
            })
    );
    helper.getView(R.id.ivAvatar).setOnClickListener(v -> {
        UserInfo userInfo = DBManager.getInstance().getUserInfo(item.getSenderUserId());
        if (userInfo != null) {
            Intent intent = new Intent(mContext, UserInfoActivity.class);
            intent.putExtra("userInfo", userInfo);
            ((SessionActivity) mContext).jumpToActivity(intent);
        }
    });
}
 
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;
    }