• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ImageMessageBody类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.easemob.chat.ImageMessageBody的典型用法代码示例。如果您正苦于以下问题:Java ImageMessageBody类的具体用法?Java ImageMessageBody怎么用?Java ImageMessageBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ImageMessageBody类属于com.easemob.chat包,在下文中一共展示了ImageMessageBody类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: forwardMessage

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 转发消息
 * 
 * @param forward_msg_id
 */
protected void forwardMessage(String forward_msg_id) {
	EMMessage forward_msg = EMChatManager.getInstance().getMessage(forward_msg_id);
	EMMessage.Type type = forward_msg.getType();
	switch (type) {
	case TXT:
		// 获取消息内容,发送消息
		String content = ((TextMessageBody) forward_msg.getBody()).getMessage();
		sendText(content);
		break;
	case IMAGE:
		// 发送图片
		String filePath = ((ImageMessageBody) forward_msg.getBody()).getLocalUrl();
		if (filePath != null) {
			File file = new File(filePath);
			if (!file.exists()) {
				// 不存在大图发送缩略图
				filePath = ImageUtils.getThumbnailImagePath(filePath);
			}
			sendPicture(filePath);
		}
		break;
	default:
		break;
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:31,代码来源:ChatActivity.java


示例2: sendPicture

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 发送图片
 * 
 * @param filePath
 */
private void sendPicture(final String filePath) {
	String to = toChatUsername;
	// create and add image message in view
	final EMMessage message = EMMessage.createSendMessage(EMMessage.Type.IMAGE);
	// 如果是群聊,设置chattype,默认是单聊
	if (chatType == CHATTYPE_GROUP)
		message.setChatType(ChatType.GroupChat);

	message.setReceipt(to);
	ImageMessageBody body = new ImageMessageBody(new File(filePath));
	// 默认超过100k的图片会压缩后发给对方,可以设置成发送原图
	// body.setSendOriginalImage(true);
	message.addBody(body);
	conversation.addMessage(message);

	listView.setAdapter(adapter);
	adapter.refresh();
	listView.setSelection(listView.getCount() - 1);
	setResult(RESULT_OK);
	// more(more);
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:27,代码来源:ChatActivity.java


示例3: removeMessage

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
private void removeMessage(){
       // 关闭显示大图的界面时判断当前消息是否是要销毁的
       EMMessage message= EMChatManager.getInstance().getMessage(msgId);
       if(message == null){
           return;
       }
       if(message.getBooleanAttribute(EaseConstant.EASE_ATTR_READFIRE, false)
               && message.direct == Direct.RECEIVE){
           ImageMessageBody body = (ImageMessageBody) message.getBody();
           File file = new File(body.getLocalUrl());
           if (file.exists() && file.isFile()) {
               file.delete();
           }
           String path = body.getLocalUrl();
           String thPath = path.substring(0, path.lastIndexOf("/")) + "/th" + path.substring(path.lastIndexOf("/") + 1);
           File thFile = new File(thPath);
           if (thFile.exists() && thFile.isFile()) {
               thFile.delete();
           }
           EMChatManager.getInstance().getConversation(message.getFrom()).removeMessage(msgId);
       }
}
 
开发者ID:easemob,项目名称:easeui,代码行数:23,代码来源:EaseShowBigImageActivity.java


示例4: sendPicture

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 发送图片
 * 
 * @param filePath
 */
private void sendPicture(final String filePath) {
	String to = toChatUsername;
	// create and add image message in view
	final EMMessage message = EMMessage.createSendMessage(EMMessage.Type.IMAGE);
	// 如果是群聊,设置chattype,默认是单聊
	if (chatType == CHATTYPE_GROUP)
		message.setChatType(ChatType.GroupChat);

	message.setReceipt(to);
	ImageMessageBody body = new ImageMessageBody(new File(filePath));
	// 默认超过100k的图片会压缩后发给对方,可以设置成发送原图
	// body.setSendOriginalImage(true);
	message.addBody(body);
	conversation.addMessage(message);

	listView.setAdapter(adapter);
	adapter.refreshSelectLast();
	setResult(RESULT_OK);
	// more(more);
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:26,代码来源:ChatActivity.java


示例5: getMessageDigest

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
	 * 根据消息内容和消息类型获取消息内容提示
	 * 
	 * @param message
	 * @param context
	 * @return
	 */
	private 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 = getStrng(context, R.string.location_recv);
				digest = String.format(digest, message.getFrom());
				return digest;
			} else {
//				digest = EasyUtils.getAppResourceString(context, "location_prefix");
				digest = getStrng(context, R.string.location_prefix);
			}
			break;
		case IMAGE: // 图片消息
			ImageMessageBody imageBody = (ImageMessageBody) message.getBody();
			digest = getStrng(context, R.string.picture) + imageBody.getFileName();
			break;
		case VOICE:// 语音消息
			digest = getStrng(context, R.string.voice);
			break;
		case VIDEO: // 视频消息
			digest = getStrng(context, R.string.video);
			break;
		case TXT: // 文本消息
			TextMessageBody txtBody = (TextMessageBody) message.getBody();
			digest = txtBody.getMessage();
			break;
		case FILE: //普通文件消息
			digest = getStrng(context, R.string.file);
			break;
		default:
			System.err.println("error, unknow type");
			return "";
		}

		return digest;
	}
 
开发者ID:macyuan,项目名称:TAG,代码行数:47,代码来源:ChatHistoryAdapter.java


示例6: forwardMessage

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 转发消息
 * 
 * @param forward_msg_id
 */
protected void forwardMessage(String forward_msg_id) {
    final EMMessage forward_msg = EMChatManager.getInstance().getMessage(forward_msg_id);
    EMMessage.Type type = forward_msg.getType();
    switch (type) {
    case TXT:
        // 获取消息内容,发送消息
        String content = ((TextMessageBody) forward_msg.getBody()).getMessage();
        sendTextMessage(content);
        break;
    case IMAGE:
        // 发送图片
        String filePath = ((ImageMessageBody) forward_msg.getBody()).getLocalUrl();
        if (filePath != null) {
            File file = new File(filePath);
            if (!file.exists()) {
                // 不存在大图发送缩略图
                filePath = EaseImageUtils.getThumbnailImagePath(filePath);
            }
            sendImageMessage(filePath);
        }
        break;
    default:
        break;
    }
    
    if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){
        EMChatManager.getInstance().leaveChatRoom(forward_msg.getTo());
    }
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:35,代码来源:EaseChatFragment.java


示例7: forwardMessage

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 转发消息
 * 
 * @param forward_msg_id
 */
protected void forwardMessage(String forward_msg_id) {
    final EMMessage forward_msg = EMChatManager.getInstance().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(((TextMessageBody) forward_msg.getBody()).getMessage(),
                    forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
        }else{
            // 获取消息内容,发送消息
            String content = ((TextMessageBody) forward_msg.getBody()).getMessage();
            sendTextMessage(content);
        }
        break;
    case IMAGE:
        // 发送图片
        String filePath = ((ImageMessageBody) forward_msg.getBody()).getLocalUrl();
        if (filePath != null) {
            File file = new File(filePath);
            if (!file.exists()) {
                // 不存在大图发送缩略图
                filePath = EaseImageUtils.getThumbnailImagePath(filePath);
            }
            sendImageMessage(filePath);
        }
        break;
    default:
        break;
    }
    
    if(forward_msg.getChatType() == EMMessage.ChatType.ChatRoom){
        EMChatManager.getInstance().leaveChatRoom(forward_msg.getTo());
    }
}
 
开发者ID:easemob,项目名称:easeui,代码行数:40,代码来源:EaseChatFragment.java


示例8: sendPicture

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 发送图片
 * 
 * @param filePath
 */
private void sendPicture(final String filePath) {
	String to = toChatUsername;
	// create and add image message in view
	final EMMessage message = EMMessage.createSendMessage(EMMessage.Type.IMAGE);
	// 如果是群聊,设置chattype,默认是单聊
	if (chatType == CHATTYPE_GROUP){
		message.setChatType(ChatType.GroupChat);
	}else if(chatType == CHATTYPE_CHATROOM){
	    message.setChatType(ChatType.ChatRoom);
	}

	message.setReceipt(to);
	ImageMessageBody body = new ImageMessageBody(new File(filePath));
	// 默认超过100k的图片会压缩后发给对方,可以设置成发送原图
	// body.setSendOriginalImage(true);
	message.addBody(body);
	if(isRobot){
		message.setAttribute("em_robot_message", true);
	}
	conversation.addMessage(message);

	listView.setAdapter(adapter);
	adapter.refreshSelectLast();
	setResult(RESULT_OK);
	// more(more);
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:32,代码来源:ChatActivity.java


示例9: forwardMessage

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 转发消息
 * 
 * @param forward_msg_id
 */
protected void forwardMessage(String forward_msg_id) {
	final EMMessage forward_msg = EMChatManager.getInstance().getMessage(forward_msg_id);
	EMMessage.Type type = forward_msg.getType();
	switch (type) {
	case TXT:
		// 获取消息内容,发送消息
		String content = ((TextMessageBody) forward_msg.getBody()).getMessage();
		sendText(content);
		break;
	case IMAGE:
		// 发送图片
		String filePath = ((ImageMessageBody) forward_msg.getBody()).getLocalUrl();
		if (filePath != null) {
			File file = new File(filePath);
			if (!file.exists()) {
				// 不存在大图发送缩略图
				filePath = ImageUtils.getThumbnailImagePath(filePath);
			}
			sendPicture(filePath);
		}
		break;
	default:
		break;
	}
	
	if(forward_msg.getChatType() == ChatType.ChatRoom){
		EMChatManager.getInstance().leaveChatRoom(forward_msg.getTo());
	}
}
 
开发者ID:chenjunqian,项目名称:here,代码行数:35,代码来源:ChatActivity.java


示例10: forwardMessage

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 转发消息
 *
 * @param forward_msg_id
 */
protected void forwardMessage(String forward_msg_id) {
    final EMMessage forward_msg = EMChatManager.getInstance().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(((TextMessageBody) forward_msg.getBody()).getMessage(),
                        forward_msg.getStringAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, null));
            } else {
                // 获取消息内容,发送消息
                String content = ((TextMessageBody) forward_msg.getBody()).getMessage();
                sendTextMessage(content);
            }
            break;
        case IMAGE:
            // 发送图片
            String filePath = ((ImageMessageBody) forward_msg.getBody()).getLocalUrl();
            if (filePath != null) {
                File file = new File(filePath);
                if (!file.exists()) {
                    // 不存在大图发送缩略图
                    filePath = EaseImageUtils.getThumbnailImagePath(filePath);
                }
                sendImageMessage(filePath);
            }
            break;
        default:
            break;
    }

    if (forward_msg.getChatType() == EMMessage.ChatType.ChatRoom) {
        EMChatManager.getInstance().leaveChatRoom(forward_msg.getTo());
    }
}
 
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:40,代码来源:EaseChatFragment.java


示例11: getMessageDigest

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * 根据消息内容和消息类型获取消息内容提示
 * 
 * @param message
 * @param context
 * @return
 */
private 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 = getStrng(context, R.string.location_recv);
			digest = String.format(digest, message.getFrom());
			return digest;
		} else {
			// digest = EasyUtils.getAppResourceString(context,
			// "location_prefix");
			digest = getStrng(context, R.string.location_prefix);
		}
		break;
	case IMAGE: // 图片消息
		ImageMessageBody imageBody = (ImageMessageBody) message.getBody();
		digest = getStrng(context, R.string.picture) + imageBody.getFileName();
		break;
	case VOICE:// 语音消息
		digest = getStrng(context, R.string.voice);
		break;
	case VIDEO: // 视频消息
		digest = getStrng(context, R.string.video);
		break;
	case TXT: // 文本消息
		TextMessageBody txtBody = (TextMessageBody) message.getBody();
		digest = txtBody.getMessage();
		break;
	case FILE: // 普通文件消息
		digest = getStrng(context, R.string.file);
		break;
	default:
		System.err.println("error, unknow type");
		return "";
	}

	return digest;
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:49,代码来源:ChatAllHistoryAdapter.java


示例12: showImageView

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
	 * load image into image view
	 * 
	 * @param thumbernailPath
	 * @param iv
	 * @param position
	 * @return the image exists or not
	 */
	private boolean showImageView(final String thumbernailPath, final ImageView iv, final String localFullSizePath, String remoteDir,
			final EMMessage message) {
//		String imagename = localFullSizePath.substring(localFullSizePath.lastIndexOf("/") + 1, localFullSizePath.length());
		// final String remote = remoteDir != null ? remoteDir+imagename :
		// imagename;
		final String remote = remoteDir;
		EMLog.d("###", "local = " + localFullSizePath + " remote: " + remote);
		// first check if the thumbnail image already loaded into cache
		Bitmap bitmap = ImageCache.getInstance().get(thumbernailPath);
		if (bitmap != null) {
			// thumbnail image is already loaded, reuse the drawable
			iv.setImageBitmap(bitmap);
			iv.setClickable(true);
			iv.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					System.err.println("image view on click");
					Intent intent = new Intent(activity, ShowBigImage.class);
					File file = new File(localFullSizePath);
					if (file.exists()) {
						Uri uri = Uri.fromFile(file);
						intent.putExtra("uri", uri);
						System.err.println("here need to check why download everytime");
					} else {
						// The local full size pic does not exist yet.
						// ShowBigImage needs to download it from the server
						// first
						// intent.putExtra("", message.get);
						ImageMessageBody body = (ImageMessageBody) message.getBody();
						intent.putExtra("secret", body.getSecret());
						intent.putExtra("remotepath", remote);
					}
					if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked
							&& message.getChatType() != ChatType.GroupChat) {
						try {
							EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
							message.isAcked = true;
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
					activity.startActivity(intent);
				}
			});
			return true;
		} else {

			new LoadImageTask().execute(thumbernailPath, localFullSizePath, remote, message.getChatType(), iv, activity, message);
			return true;
		}

	}
 
开发者ID:macyuan,项目名称:TAG,代码行数:61,代码来源:MessageAdapter.java


示例13: showImageView

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * load image into image view
 * 
 * @param thumbernailPath
 * @param iv
 * @param position
 * @return the image exists or not
 */
private boolean showImageView(final String thumbernailPath, final ImageView iv, final String localFullSizePath, String remoteDir,
		final EMMessage message) {
	// String imagename =
	// localFullSizePath.substring(localFullSizePath.lastIndexOf("/") + 1,
	// localFullSizePath.length());
	// final String remote = remoteDir != null ? remoteDir+imagename :
	// imagename;
	final String remote = remoteDir;
	EMLog.d("###", "local = " + localFullSizePath + " remote: " + remote);
	// first check if the thumbnail image already loaded into cache
	Bitmap bitmap = ImageCache.getInstance().get(thumbernailPath);
	if (bitmap != null) {
		// thumbnail image is already loaded, reuse the drawable
		iv.setImageBitmap(bitmap);
		iv.setClickable(true); 
		iv.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				System.err.println("image view on click");
				Intent intent = new Intent(activity, ShowBigImage.class);
				File file = new File(localFullSizePath);
				if (file.exists()) {
					Uri uri = Uri.fromFile(file);
					intent.putExtra("uri", uri);
					System.err.println("here need to check why download everytime");
				} else {
					// The local full size pic does not exist yet.
					// ShowBigImage needs to download it from the server
					// first
					// intent.putExtra("", message.get);
					ImageMessageBody body = (ImageMessageBody) message.getBody();
					intent.putExtra("secret", body.getSecret());
					intent.putExtra("remotepath", remote);
				}
				if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked
						&& message.getChatType() != ChatType.GroupChat) {
					try {
						EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
						message.isAcked = true;
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				activity.startActivity(intent);
			}
		});
		return true;
	} else {

		new LoadImageTask().execute(thumbernailPath, localFullSizePath, remote, message.getChatType(), iv, activity, message);
		return true;
	}

}
 
开发者ID:Owater,项目名称:school_shop,代码行数:63,代码来源:MessageAdapter.java


示例14: showImageView

import com.easemob.chat.ImageMessageBody; //导入依赖的package包/类
/**
 * load image into image view
 * 
 * @param thumbernailPath
 * @param iv
 * @return the image exists or not
 */
private boolean showImageView(final String thumbernailPath, final ImageView iv, final String localFullSizePath, String remoteDir,
		final EMMessage message) {
	// String imagename =
	// localFullSizePath.substring(localFullSizePath.lastIndexOf("/") + 1,
	// localFullSizePath.length());
	// final String remote = remoteDir != null ? remoteDir+imagename :
	// imagename;
	final String remote = remoteDir;
	EMLog.d("###", "local = " + localFullSizePath + " remote: " + remote);
	// first check if the thumbnail image already loaded into cache
	Bitmap bitmap = ImageCache.getInstance().get(thumbernailPath);
	if (bitmap != null) {
		// thumbnail image is already loaded, reuse the drawable
		iv.setImageBitmap(bitmap);
		iv.setClickable(true); 
		iv.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				EMLog.d(TAG, "image view on click");
				Intent intent = new Intent(activity, ShowBigImage.class);
				File file = new File(localFullSizePath);
				if (file.exists()) {
					Uri uri = Uri.fromFile(file);
					intent.putExtra("uri", uri);
					EMLog.d(TAG, "here need to check why download everytime");
				} else {
					// The local full size pic does not exist yet.
					// ShowBigImage needs to download it from the server
					// first
					// intent.putExtra("", message.get);
					ImageMessageBody body = (ImageMessageBody) message.getBody();
					intent.putExtra("secret", body.getSecret());
					intent.putExtra("remotepath", remote);
				}
				if (message != null && message.direct == Direct.RECEIVE && !message.isAcked
						&& message.getChatType() != ChatType.GroupChat && message.getChatType() != ChatType.ChatRoom) {
					try {
						EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
						message.isAcked = true;
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				activity.startActivity(intent);
			}
		});
		return true;
	} else {

		new LoadImageTask().execute(thumbernailPath, localFullSizePath, remote, message.getChatType(), iv, activity, message);
		return true;
	}

}
 
开发者ID:chenjunqian,项目名称:here,代码行数:62,代码来源:MessageAdapter.java



注:本文中的com.easemob.chat.ImageMessageBody类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Memory类代码示例发布时间:2022-05-23
下一篇:
Java YarnJacksonJaxbJsonProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap