io.rong.imlib.model.MessageContent Java Examples
The following examples show how to use
io.rong.imlib.model.MessageContent.
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: SealAppContext.java From sealtalk-android with MIT License | 6 votes |
@Override public boolean onConversationClick(Context context, View view, UIConversation uiConversation) { MessageContent messageContent = uiConversation.getMessageContent(); if (messageContent instanceof ContactNotificationMessage) { ContactNotificationMessage contactNotificationMessage = (ContactNotificationMessage) messageContent; if (contactNotificationMessage.getOperation().equals("AcceptResponse")) { // 被加方同意请求后 if (contactNotificationMessage.getExtra() != null) { ContactNotificationMessageData bean = null; try { bean = JsonMananger.jsonToBean(contactNotificationMessage.getExtra(), ContactNotificationMessageData.class); } catch (HttpException e) { e.printStackTrace(); } RongIM.getInstance().startPrivateChat(context, uiConversation.getConversationSenderId(), bean.getSourceUserNickname()); } } else { context.startActivity(new Intent(context, NewFriendListActivity.class)); } return true; } return false; }
Example #2
Source File: SessionAdapter.java From LQRWeChat with MIT License | 5 votes |
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 #3
Source File: SessionAdapter.java From LQRWeChat with MIT License | 5 votes |
@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 #4
Source File: NewDiscussionConversationProvider.java From sealtalk-android with MIT License | 5 votes |
/** * @ 消息提示 * @param holder * @param data */ private void setDateView(ViewHolder holder, UIConversation data) { String userId = null; String username = null; if (SharedPreferencesContext.getInstance() != null) { userId = SharedPreferencesContext.getInstance().getSharedPreferences().getString(Constants.APP_USER_ID, Constants.DEFAULT); username = SharedPreferencesContext.getInstance().getSharedPreferences().getString(Constants.APP_USER_NAME, Constants.DEFAULT); } MessageContent messageContent = data.getMessageContent(); if (messageContent instanceof TextMessage) { if (((TextMessage) messageContent).getContent().contains("@" + userId) || ((TextMessage) messageContent).getContent().contains("@" + username)) { if (data.getUnReadMessageCount() == 0) { holder.atMe.setVisibility(View.GONE); data.setExtraFlag(false); } else if (data.getUnReadMessageCount() > 0) { holder.atMe.setVisibility(View.VISIBLE); data.setExtraFlag(true); } } else { if (data.getExtraFlag()) { holder.atMe.setVisibility(View.VISIBLE); } else { holder.atMe.setVisibility(View.GONE); data.setExtraFlag(false); } if (data.getUnReadMessageCount() == 0) { holder.atMe.setVisibility(View.GONE); data.setExtraFlag(false); } } } }
Example #5
Source File: SealAppContext.java From sealtalk-android with MIT License | 4 votes |
@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; }