use of com.hyphenate.chat.EMTextMessageBody in project SmartCampus by Vegen.
the class EaseDingMessageHelperTest method createDingMessage.
private EMMessage createDingMessage(String conversationId, String originalMsgId) {
EMAMessage _msg = EMAMessage.createSendMessage("", "", null, EMMessage.ChatType.Chat.ordinal());
_msg.setTo(conversationId);
EMMessage msg = new EMMessage(_msg);
msg.setMsgId(originalMsgId);
EMTextMessageBody txtBody = new EMTextMessageBody("1");
msg.addBody(txtBody);
msg.setAttribute(KEY_DING, true);
msg.setChatType(EMMessage.ChatType.GroupChat);
return msg;
}
use of com.hyphenate.chat.EMTextMessageBody in project SmartCampus by Vegen.
the class EaseChatFragment method forwardMessage.
/**
* forward message
*
* @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 {
// get the content and send it
String content = ((EMTextMessageBody) forward_msg.getBody()).getMessage();
sendTextMessage(content);
}
break;
case IMAGE:
// send image
String filePath = ((EMImageMessageBody) forward_msg.getBody()).getLocalUrl();
if (filePath != null) {
File file = new File(filePath);
if (!file.exists()) {
// send thumb nail if original image does not exist
filePath = ((EMImageMessageBody) forward_msg.getBody()).thumbnailLocalPath();
}
sendImageMessage(filePath);
}
break;
default:
break;
}
if (forward_msg.getChatType() == ChatType.ChatRoom) {
EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo());
}
}
use of com.hyphenate.chat.EMTextMessageBody in project SmartCampus by Vegen.
the class EaseCommonUtils method getMessageDigest.
/**
* 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;
}
use of com.hyphenate.chat.EMTextMessageBody in project SmartCampus by Vegen.
the class EaseChatRowText method onSetUpView.
@Override
public void onSetUpView() {
EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
// 设置内容
contentView.setText(span, BufferType.SPANNABLE);
}
Aggregations