com.hyphenate.chat.EMImageMessageBody Java Examples
The following examples show how to use
com.hyphenate.chat.EMImageMessageBody.
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: HxImageDetailPresenter.java From FamilyChat with Apache License 2.0 | 6 votes |
public void savePic(Context context, EMMessage message) { if (message == null) return; mViewImpl.showDownloadDialog(); EMImageMessageBody messageBody = (EMImageMessageBody) message.getBody(); String remoteUrl = messageBody.getRemoteUrl(); CommonUtils.getInstance().getImageDisplayer().downloadBitmap(context, remoteUrl, new OnBitmapDownloadListener() { @Override public void onDownload(Bitmap bitmap) { saveBitmap(bitmap); } }); }
Example #2
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 #3
Source File: MyEaseChatFragment.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() == EMMessage.ChatType.ChatRoom){ EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo()); } }
Example #4
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 #5
Source File: EaseChatFragment.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
/** * 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() == EMMessage.ChatType.ChatRoom){ EMClient.getInstance().chatroomManager().leaveChatRoom(forward_msg.getTo()); } }
Example #6
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 #7
Source File: HxImageDetailAdapter.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(mActivity); photoView.setBackgroundColor(Color.BLACK); photoView.setScaleType(ImageView.ScaleType.FIT_CENTER); photoView.setEnabled(true); EMImageMessageBody messageBody = (EMImageMessageBody) mDataList.get(position).getBody(); String localUrl = messageBody.getLocalUrl(); String remoteUrl = messageBody.getRemoteUrl(); if (StringUtil.isNotEmpty(localUrl) && new File(localUrl).exists()) CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, localUrl, mScreenWidth, mScreenHeight , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail); else CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, remoteUrl, mScreenWidth, mScreenHeight , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail); photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { if (mListener != null) mListener.OnPhotoTapListener(view, x, y); } }); container.addView(photoView); return photoView; }
Example #8
Source File: ImageMessageBaseItemView.java From FamilyChat with Apache License 2.0 | 4 votes |
@Override public void setMessageData(RcvHolder holder, final EMMessage emMessage, final int position) { EMImageMessageBody messageBody = (EMImageMessageBody) emMessage.getBody(); //根据图片高度计算ImageView的尺寸 int imgWidth = messageBody.getWidth(); int imgHeight = messageBody.getHeight(); if (imgWidth >= MAX_IMAGE_SIZE) { mLayoutWidth = MAX_IMAGE_SIZE; mLayoutHeight = mLayoutWidth * imgHeight / imgWidth; } else if (imgHeight >= MAX_IMAGE_SIZE) { mLayoutHeight = MAX_IMAGE_SIZE; mLayoutWidth = mLayoutHeight * imgWidth / imgHeight; } else { mLayoutWidth = imgWidth >= MIN_IMAGE_SIZE ? imgWidth : MIN_IMAGE_SIZE; mLayoutHeight = imgHeight >= MIN_IMAGE_SIZE ? imgHeight : MIN_IMAGE_SIZE; } SelectableRoundedImageView imageView = holder.findView(R.id.img_chat_listitem_img_content); ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams(); layoutParams.width = mLayoutWidth + PADDING_LEFT + PADDING_RIGHT; layoutParams.height = mLayoutHeight + PADDING_TOP + PADDING_BOTTOM; imageView.setLayoutParams(layoutParams); //判断显示图地址 String localUrl = messageBody.getLocalUrl(); String remoteUrl = messageBody.getRemoteUrl(); if (emMessage.direct() == EMMessage.Direct.SEND && StringUtil.isNotEmpty(localUrl) && new File(localUrl).exists()) CommonUtils.getInstance().getImageDisplayer() .display(mContext, imageView, localUrl, mLayoutWidth, mLayoutHeight); else CommonUtils.getInstance().getImageDisplayer() .display(mContext, imageView, remoteUrl, mLayoutWidth, mLayoutHeight); //设置点击事件 imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mPresenter.clickImageMessage(emMessage, position); } }); setMessage(holder, emMessage, position); }