use of com.hyphenate.chat.EMImageMessageBody in project SmartCampus by Vegen.
the class EaseChatImagePresenter method onBubbleClick.
@Override
public void onBubbleClick(EMMessage message) {
EMImageMessageBody imgBody = (EMImageMessageBody) message.getBody();
if (EMClient.getInstance().getOptions().getAutodownloadThumbnail()) {
if (imgBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.FAILED) {
getChatRow().updateView(message);
// retry download with click event of user
EMClient.getInstance().chatManager().downloadThumbnail(message);
}
} else {
if (imgBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.DOWNLOADING || imgBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.PENDING || imgBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.FAILED) {
// retry download with click event of user
EMClient.getInstance().chatManager().downloadThumbnail(message);
getChatRow().updateView(message);
return;
}
}
Intent intent = new Intent(getContext(), EaseShowBigImageActivity.class);
File file = new File(imgBody.getLocalUrl());
if (file.exists()) {
Uri uri = Uri.fromFile(file);
intent.putExtra("uri", uri);
} else {
// The local full size pic does not exist yet.
// ShowBigImage needs to download it from the server
// first
String msgId = message.getMsgId();
intent.putExtra("messageId", msgId);
intent.putExtra("localUrl", imgBody.getLocalUrl());
}
if (message != null && message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == EMMessage.ChatType.Chat) {
try {
EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (Exception e) {
e.printStackTrace();
}
}
getContext().startActivity(intent);
}
use of com.hyphenate.chat.EMImageMessageBody 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());
}
}
Aggregations