Java Code Examples for com.hyphenate.chat.EMMessage#getType()
The following examples show how to use
com.hyphenate.chat.EMMessage#getType() .
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: HxChatPresenter.java From FamilyChat with Apache License 2.0 | 6 votes |
/** * 重新发送某条消息 */ public void resendMessage(EMMessage message, int position) { EMConversation.EMConversationType conType = mViewImpl.getConversationType(); String conId = mViewImpl.getConversationId(); //移除已有消息 HxChatHelper.getInstance().deleteMessage(conType, conId, message); mViewImpl.removeMessage(message, position); //重发消息 switch (message.getType()) { case TXT: EMTextMessageBody textMessageBody = (EMTextMessageBody) message.getBody(); sendTextMessage(conType, conId, textMessageBody.getMessage()); break; case VOICE: EMVoiceMessageBody voiceMessageBody = (EMVoiceMessageBody) message.getBody(); sendVoiceMessage(conType, conId, voiceMessageBody.getLocalUrl(), voiceMessageBody.getLength()); break; case IMAGE: EMImageMessageBody imageMessageBody = (EMImageMessageBody) message.getBody(); sendImageMessage(conType, conId, imageMessageBody.getLocalUrl(), imageMessageBody.isSendOriginalImage()); break; } }
Example 2
Source File: EaseChatFragment.java From nono-android with GNU General Public License v3.0 | 5 votes |
/** * 转发消息 * * @param forward_msg_id */ protected void forwardMessage(String forward_msg_id) { final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id); EMMessage.Type type = forward_msg.getType(); switch (type) { case TXT: if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(), forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null)); }else{ // 获取消息内容,发送消息 String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage(); sendTextMessage(content); } break; case IMAGE: // 发送图片 String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl(); if (filePath != null) { File file = new File(filePath); if (!file.exists()) { // 不存在大图发送缩略图 filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath(); } sendImageMessage(filePath); } break; default: break; } if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){ EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo()); } }
Example 3
Source File: LeftImageMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { if (item.direct() == EMMessage.Direct.RECEIVE && item.getType() == EMMessage.Type.IMAGE) return true; else return false; }
Example 4
Source File: LeftVideoRecordItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { int attr = item.getIntAttribute(HxMsgAttrConstant.TXT_ATTR_KEY, HxMsgAttrConstant.NORMAL_TEXT_MSG); if (item.direct() == EMMessage.Direct.RECEIVE && item.getType() == EMMessage.Type.TXT && attr == HxMsgAttrConstant.VIDEO_CALL_RECORD) return true; else return false; }
Example 5
Source File: RightVideoMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { if (item.direct() == EMMessage.Direct.SEND && item.getType() == EMMessage.Type.VIDEO) return true; else return false; }
Example 6
Source File: LeftTextMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { int attr = item.getIntAttribute(HxMsgAttrConstant.TXT_ATTR_KEY, HxMsgAttrConstant.NORMAL_TEXT_MSG); if (item.direct() == EMMessage.Direct.RECEIVE && item.getType() == EMMessage.Type.TXT && attr == HxMsgAttrConstant.NORMAL_TEXT_MSG) return true; else return false; }
Example 7
Source File: RightVoiceRecordItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { int attr = item.getIntAttribute(HxMsgAttrConstant.TXT_ATTR_KEY, HxMsgAttrConstant.NORMAL_TEXT_MSG); if (item.direct() == EMMessage.Direct.SEND && item.getType() == EMMessage.Type.TXT && attr == HxMsgAttrConstant.VOICE_CALL_RECORD) return true; else return false; }
Example 8
Source File: RightTextMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { int attr = item.getIntAttribute(HxMsgAttrConstant.TXT_ATTR_KEY, HxMsgAttrConstant.NORMAL_TEXT_MSG); if (item.direct() == EMMessage.Direct.SEND && item.getType() == EMMessage.Type.TXT && attr == HxMsgAttrConstant.NORMAL_TEXT_MSG) return true; else return false; }
Example 9
Source File: EaseMessageAdapter.java From nono-android with GNU General Public License v3.0 | 5 votes |
protected EaseChatRow createChatRow(Context context, EMMessage message, int position) { EaseChatRow chatRow = null; if(customRowProvider != null && customRowProvider.getCustomChatRow(message, position, this) != null){ return customRowProvider.getCustomChatRow(message, position, this); } switch (message.getType()) { case TXT: if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ chatRow = new EaseChatRowBigExpression(context, message, position, this); }else{ chatRow = new EaseChatRowText(context, message, position, this); } break; case LOCATION: //chatRow = new EaseChatRowLocation(context, message, position, this); break; case FILE: //chatRow = new EaseChatRowFile(context, message, position, this); break; case IMAGE: //chatRow = new EaseChatRowImage(context, message, position, this); break; case VOICE: //chatRow = new EaseChatRowVoice(context, message, position, this); break; case VIDEO: //chatRow = new EaseChatRowVideo(context, message, position, this); break; default: break; } return chatRow; }
Example 10
Source File: EaseMessageAdapter.java From nono-android with GNU General Public License v3.0 | 5 votes |
/** * 获取item类型 */ public int getItemViewType(int position) { EMMessage message = getItem(position); if (message == null) { return -1; } if(customRowProvider != null && customRowProvider.getCustomChatRowType(message) > 0){ return customRowProvider.getCustomChatRowType(message) + 13; } if (message.getType() == EMMessage.Type.TXT) { if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_EXPRESSION : MESSAGE_TYPE_SENT_EXPRESSION; } return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT; } if (message.getType() == EMMessage.Type.IMAGE) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE; } if (message.getType() == EMMessage.Type.LOCATION) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION; } if (message.getType() == EMMessage.Type.VOICE) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE; } if (message.getType() == EMMessage.Type.VIDEO) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO; } if (message.getType() == EMMessage.Type.FILE) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE; } return -1;// invalid }
Example 11
Source File: RightImageMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { if (item.direct() == EMMessage.Direct.SEND && item.getType() == EMMessage.Type.IMAGE) return true; else return false; }
Example 12
Source File: RightVoiceMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { if (item.direct() == EMMessage.Direct.SEND && item.getType() == EMMessage.Type.VOICE) return true; else return false; }
Example 13
Source File: RightVideoRecordItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { int attr = item.getIntAttribute(HxMsgAttrConstant.TXT_ATTR_KEY, HxMsgAttrConstant.NORMAL_TEXT_MSG); if (item.direct() == EMMessage.Direct.SEND && item.getType() == EMMessage.Type.TXT && attr == HxMsgAttrConstant.VIDEO_CALL_RECORD) return true; else return false; }
Example 14
Source File: EaseMessageAdapter.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
/** * get type of item */ public int getItemViewType(int position) { EMMessage message = getItem(position); if (message == null) { return -1; } if(customRowProvider != null && customRowProvider.getCustomChatRowType(message) > 0){ return customRowProvider.getCustomChatRowType(message) + 13; } if (message.getType() == EMMessage.Type.TXT) { if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_EXPRESSION : MESSAGE_TYPE_SENT_EXPRESSION; } return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT; } if (message.getType() == EMMessage.Type.IMAGE) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE; } if (message.getType() == EMMessage.Type.LOCATION) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION; } if (message.getType() == EMMessage.Type.VOICE) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE; } if (message.getType() == EMMessage.Type.VIDEO) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO; } if (message.getType() == EMMessage.Type.FILE) { return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE; } return -1;// invalid }
Example 15
Source File: EaseChatFragment.java From Social with Apache License 2.0 | 5 votes |
/** * 转发消息 * * @param forward_msg_id */ protected void forwardMessage(String forward_msg_id) { final EMMessage forward_msg = EMClient.getInstance().chatManager().getMessage(forward_msg_id); EMMessage.Type type = forward_msg.getType(); switch (type) { case TXT: if(forward_msg.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ sendBigExpressionMessage(((EMTextMessageBody) forward_msg.getBody()).getMessage(), forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null)); }else{ // 获取消息内容,发送消息 String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage(); sendTextMessage(content); } break; case IMAGE: // 发送图片 String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl(); if (filePath != null) { File file = new File(filePath); if (!file.exists()) { // 不存在大图发送缩略图 filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath(); } sendImageMessage(filePath); } break; default: break; } if(forward_msg.getChatType() == ChatType.ChatRoom){ EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo()); } }
Example 16
Source File: LeftVoiceMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { if (item.direct() == EMMessage.Direct.RECEIVE && item.getType() == EMMessage.Type.VOICE) return true; else return false; }
Example 17
Source File: LeftVideoMessageItemView.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public boolean isForViewType(EMMessage item, int position) { if (item.direct() == EMMessage.Direct.RECEIVE && item.getType() == EMMessage.Type.VIDEO) return true; else return false; }
Example 18
Source File: MyEaseChatFragment.java From Social with Apache License 2.0 | 5 votes |
@Override public int getCustomChatRowType(EMMessage message) { if(message.getType() == EMMessage.Type.TXT){ //voice call if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)){ return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE_CALL : MESSAGE_TYPE_SENT_VOICE_CALL; }else if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)){ //video call return message.direct() == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO_CALL : MESSAGE_TYPE_SENT_VIDEO_CALL; } } return 0; }
Example 19
Source File: EaseCommonUtils.java From nono-android with GNU General Public License v3.0 | 4 votes |
/** * 根据消息内容和消息类型获取消息内容提示 * * @param message * @param context * @return */ public static String getMessageDigest(EMMessage message, Context context) { String digest = ""; switch (message.getType()) { case LOCATION: // 位置消息 if (message.direct() == EMMessage.Direct.RECEIVE) { //从sdk中提到了ui中,使用更简单不犯错的获取string方法 // digest = EasyUtils.getAppResourceString(context, "location_recv"); digest = getString(context, R.string.location_recv); digest = String.format(digest, message.getFrom()); return digest; } else { // digest = EasyUtils.getAppResourceString(context, "location_prefix"); digest = getString(context, R.string.location_prefix); } break; case IMAGE: // 图片消息 digest = getString(context, R.string.picture); break; case VOICE:// 语音消息 digest = getString(context, R.string.voice_prefix); break; case VIDEO: // 视频消息 digest = getString(context, R.string.video); break; case TXT: // 文本消息 EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody(); /*if(((DemoHXSDKHelper)HXSDKHelper.getInstance()).isRobotMenuMessage(message)){ digest = ((DemoHXSDKHelper)HXSDKHelper.getInstance()).getRobotMenuMessageDigest(message); }else */if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){ digest = getString(context, R.string.voice_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ if(!TextUtils.isEmpty(txtBody.getMessage())){ digest = txtBody.getMessage(); }else{ digest = getString(context, R.string.dynamic_expression); } }else{ digest = txtBody.getMessage(); } break; case FILE: //普通文件消息 digest = getString(context, R.string.file); break; default: EMLog.e(TAG, "error, unknow type"); return ""; } return digest; }
Example 20
Source File: EaseCommonUtils.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
/** * Get digest according message type and content * * @param message * @param context * @return */ public static String getMessageDigest(EMMessage message, Context context) { String digest = ""; switch (message.getType()) { case LOCATION: if (message.direct() == EMMessage.Direct.RECEIVE) { digest = getString(context, R.string.location_recv); digest = String.format(digest, message.getFrom()); return digest; } else { digest = getString(context, R.string.location_prefix); } break; case IMAGE: digest = getString(context, R.string.picture); break; case VOICE: digest = getString(context, R.string.voice_prefix); break; case VIDEO: digest = getString(context, R.string.video); break; case TXT: EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody(); if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){ digest = getString(context, R.string.voice_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VIDEO_CALL, false)){ digest = getString(context, R.string.video_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ if(!TextUtils.isEmpty(txtBody.getMessage())){ digest = txtBody.getMessage(); }else{ digest = getString(context, R.string.dynamic_expression); } }else{ digest = txtBody.getMessage(); } break; case FILE: digest = getString(context, R.string.file); break; default: EMLog.e(TAG, "error, unknow type"); return ""; } return digest; }