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

Java ChatType类代码示例

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

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



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

示例1: sendText

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
/**
 * 发送文本消息
 * 
 * @param content
 *            message content
 * @param isResend
 *            boolean resend
 */
private void sendText(String content) {

	if (content.length() > 0) {
		EMMessage message = EMMessage.createSendMessage(EMMessage.Type.TXT);
		// 如果是群聊,设置chattype,默认是单聊
		if (chatType == CHATTYPE_GROUP)
			message.setChatType(ChatType.GroupChat);
		TextMessageBody txtBody = new TextMessageBody(content);
		// 设置消息body
		message.addBody(txtBody);
		// 设置要发给谁,用户username或者群聊groupid
		message.setReceipt(toChatUsername);
		// 把messgage加到conversation中
		conversation.addMessage(message);
		// 通知adapter有消息变动,adapter会根据加入的这条message显示消息和调用sdk的发送方法
		adapter.refresh();
		listView.setSelection(listView.getCount() - 1);
		mEditTextContent.setText("");

		setResult(RESULT_OK);

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


示例2: sendVoice

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
/**
 * 发送语音
 * 
 * @param filePath
 * @param fileName
 * @param length
 * @param isResend
 */
private void sendVoice(String filePath, String fileName, String length, boolean isResend) {
	if (!(new File(filePath).exists())) {
		return;
	}
	try {
		final EMMessage message = EMMessage.createSendMessage(EMMessage.Type.VOICE);
		// 如果是群聊,设置chattype,默认是单聊
		if (chatType == CHATTYPE_GROUP)
			message.setChatType(ChatType.GroupChat);
		String to = toChatUsername;
		message.setReceipt(to);
		int len = Integer.parseInt(length);
		VoiceMessageBody body = new VoiceMessageBody(new File(filePath), len);
		message.addBody(body);

		conversation.addMessage(message);
		adapter.refresh();
		listView.setSelection(listView.getCount() - 1);
		setResult(RESULT_OK);
		// send file
		// sendVoiceSub(filePath, fileName, message);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:34,代码来源:ChatActivity.java


示例3: sendPicture

import com.easemob.chat.EMMessage.ChatType; //导入依赖的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


示例4: sendVideo

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
/**
 * 发送视频消息
 */
private void sendVideo(final String filePath, final String thumbPath, final int length) {
	final File videoFile = new File(filePath);
	if (!videoFile.exists()) {
		return;
	}
	try {
		EMMessage message = EMMessage.createSendMessage(EMMessage.Type.VIDEO);
		// 如果是群聊,设置chattype,默认是单聊
		if (chatType == CHATTYPE_GROUP)
			message.setChatType(ChatType.GroupChat);
		String to = toChatUsername;
		message.setReceipt(to);
		VideoMessageBody body = new VideoMessageBody(videoFile, thumbPath, length, videoFile.length());
		message.addBody(body);
		conversation.addMessage(message);
		listView.setAdapter(adapter);
		adapter.refresh();
		listView.setSelection(listView.getCount() - 1);
		setResult(RESULT_OK);
	} catch (Exception e) {
		e.printStackTrace();
	}

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


示例5: sendLocationMsg

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
/**
 * 发送位置信息
 * 
 * @param latitude
 * @param longitude
 * @param imagePath
 * @param locationAddress
 */
private void sendLocationMsg(double latitude, double longitude, String imagePath, String locationAddress) {
	EMMessage message = EMMessage.createSendMessage(EMMessage.Type.LOCATION);
	// 如果是群聊,设置chattype,默认是单聊
	if (chatType == CHATTYPE_GROUP)
		message.setChatType(ChatType.GroupChat);
	LocationMessageBody locBody = new LocationMessageBody(locationAddress, latitude, longitude);
	message.addBody(locBody);
	message.setReceipt(toChatUsername);
	conversation.addMessage(message);
	listView.setAdapter(adapter);
	adapter.notifyDataSetChanged();
	listView.setSelection(listView.getCount() - 1);
	setResult(RESULT_OK);

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


示例6: onReceive

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	String username = intent.getStringExtra("from");
	String msgid = intent.getStringExtra("msgid");
	// 收到这个广播的时候,message已经在db和内存里了,可以通过id获取mesage对象
	EMMessage message = EMChatManager.getInstance().getMessage(msgid);
	// 如果是群聊消息,获取到group id
	if (message.getChatType() == ChatType.GroupChat) {
		username = message.getTo();
	}
	if (!username.equals(toChatUsername)) {
		// 消息不是发给当前会话,return
		return;
	}
				// conversation =
	// EMChatManager.getInstance().getConversation(toChatUsername);
	// 通知adapter有新消息,更新ui
	adapter.refresh();
	listView.setSelection(listView.getCount() - 1);
	// 记得把广播给终结掉
	abortBroadcast();
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:23,代码来源:ChatActivity.java


示例7: onApplicationAccept

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {
	//加群申请被同意
	EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
	msg.setChatType(ChatType.GroupChat);
	msg.setFrom(accepter);
	msg.setTo(groupId);
	msg.setMsgId(UUID.randomUUID().toString());
	msg.addBody(new TextMessageBody(accepter + "同意了你的群聊申请"));
	// 保存同意消息
	EMChatManager.getInstance().saveMessage(msg);
	// 提醒新消息
	EMNotifier.getInstance(getApplicationContext()).notifyOnNewMsg();

	runOnUiThread(new Runnable() {
		public void run() {
			updateUnreadLabel();
			// 刷新ui
			if (currentTabIndex == CHATHISTORYFRAGMENT)
				chatHistoryFragment.refresh();
			if (CommonUtils.getTopActivity(MainActivity_0903.this).equals(GroupsActivity.class.getName())) {
				GroupsActivity.instance.onResume();
			}
		}
	});
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:27,代码来源:MainActivity_0903.java


示例8: onApplicationAccept

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {
	//加群申请被同意
	EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
	msg.setChatType(ChatType.GroupChat);
	msg.setFrom(accepter);
	msg.setTo(groupId);
	msg.setMsgId(UUID.randomUUID().toString());
	msg.addBody(new TextMessageBody(accepter + "同意了你的群聊申请"));
	// 保存同意消息
	EMChatManager.getInstance().saveMessage(msg);
	// 提醒新消息
	EMNotifier.getInstance(getApplicationContext()).notifyOnNewMsg();

	runOnUiThread(new Runnable() {
		public void run() {
			updateUnreadLabel();
			// 刷新ui
			if (currentTabIndex == CHATHISTORYFRAGMENT)
				chatHistoryFragment.refresh();
			if (CommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) {
				GroupsActivity.instance.onResume();
			}
		}
	});
}
 
开发者ID:macyuan,项目名称:TAG,代码行数:27,代码来源:MainActivity.java


示例9: doInBackground

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
	protected Bitmap doInBackground(Object... args) {
		thumbnailPath = (String)args[0];
		localFullSizePath = (String)args[1];
        remotePath = (String)args[2];
		chatType = (ChatType) args[3];		
		iv = (ImageView)args[4];		
//		if(args[2] != null) {
		    activity = (Activity) args[5];
//		}
		message = (EMMessage) args[6];
		File file = new File(thumbnailPath);
		if(file.exists()){
			return ImageUtils.decodeScaleImage(thumbnailPath, 120, 120);
		}
		else{
			if(message.direct==EMMessage.Direct.SEND)
			{
				return ImageUtils.decodeScaleImage(localFullSizePath, 120, 120);
			}else{
				return null;
			}
		}
		
	}
 
开发者ID:macyuan,项目名称:TAG,代码行数:26,代码来源:LoadImageTask.java


示例10: sendMessage

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
protected void sendMessage(EMMessage message){
    if(chatFragmentListener != null){
        //设置扩展属性
        chatFragmentListener.onSetMessageAttributes(message);
    }
    // 如果是群聊,设置chattype,默认是单聊
    if (chatType == EaseConstant.CHATTYPE_GROUP){
        message.setChatType(ChatType.GroupChat);
    }else if(chatType == EaseConstant.CHATTYPE_CHATROOM){
        message.setChatType(ChatType.ChatRoom);
    }
    //发送消息
    EMChatManager.getInstance().sendMessage(message, null);
    //刷新ui
    messageList.refreshSelectLast();
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:17,代码来源:EaseChatFragment.java


示例11: onBubbleClick

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
    Intent intent = new Intent(context, 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
        intent.putExtra("secret", imgBody.getSecret());
        intent.putExtra("remotepath", imgBody.getRemoteUrl());
    }
    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();
        }
    }
    context.startActivity(intent);
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:26,代码来源:EaseChatRowImage.java


示例12: onBubbleClick

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
    VideoMessageBody videoBody = (VideoMessageBody) message.getBody();
       EMLog.d(TAG, "video view is on click");
       Intent intent = new Intent(context, EaseShowVideoActivity.class);
       intent.putExtra("localpath", videoBody.getLocalUrl());
       intent.putExtra("secret", videoBody.getSecret());
       intent.putExtra("remotepath", videoBody.getRemoteUrl());
       if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked
               && message.getChatType() != ChatType.GroupChat) {
           message.isAcked = true;
           try {
               EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
           } catch (Exception e) {
               e.printStackTrace();
           }
       }
       activity.startActivity(intent);
}
 
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:20,代码来源:EaseChatRowVideo.java


示例13: doInBackground

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
protected Bitmap doInBackground(Object... args) {
	thumbnailPath = (String) args[0];
	localFullSizePath = (String) args[1];
	remotePath = (String) args[2];
	chatType = (ChatType) args[3];
	iv = (ImageView) args[4];
	// if(args[2] != null) {
	activity = (Activity) args[5];
	// }
	message = (EMMessage) args[6];
	File file = new File(thumbnailPath);
	if (file.exists()) {
		return ImageUtils.decodeScaleImage(thumbnailPath, 160, 160);
	} else {
		if (message.direct == EMMessage.Direct.SEND) {
			return ImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
		} else {
			return null;
		}
	}
	

}
 
开发者ID:tengbinlive,项目名称:info_demo,代码行数:25,代码来源:LoadImageTask.java


示例14: onApplicationAccept

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
public void onApplicationAccept(String groupId, String groupName, String accepter) {

    String st4 = appContext.getString(R.string.Agreed_to_your_group_chat_application);
    // 加群申请被同意
    EMMessage msg = EMMessage.createReceiveMessage(Type.TXT);
    msg.setChatType(ChatType.GroupChat);
    msg.setFrom(accepter);
    msg.setTo(groupId);
    msg.setMsgId(UUID.randomUUID().toString());
    msg.addBody(new TextMessageBody(accepter + " " +st4));
    // 保存同意消息
    EMChatManager.getInstance().saveMessage(msg);
    // 提醒新消息
    getNotifier().viberateAndPlayTone(msg);
    broadcastManager.sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
}
 
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:18,代码来源:DemoHelper.java


示例15: sendMessage

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
protected void sendMessage(EMMessage message){
    if(chatFragmentHelper != null){
        //设置扩展属性
        chatFragmentHelper.onSetMessageAttributes(message);
    }
    // 如果是群聊,设置chattype,默认是单聊
    if (chatType == EaseConstant.CHATTYPE_GROUP){
        message.setChatType(ChatType.GroupChat);
    }else if(chatType == EaseConstant.CHATTYPE_CHATROOM){
        message.setChatType(ChatType.ChatRoom);
    }
    //发送消息
    EMChatManager.getInstance().sendMessage(message, null);
    //刷新ui
    messageList.refreshSelectLast();
}
 
开发者ID:easemob,项目名称:easeui,代码行数:17,代码来源:EaseChatFragment.java


示例16: onBubbleClick

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
    Intent intent = new Intent(context, EaseShowBigImageActivity.class);
    File file = new File(imgBody.getLocalUrl());
    if (file.exists()) {
        Uri uri = Uri.fromFile(file);
        intent.putExtra("uri", uri);
        intent.putExtra(EaseConstant.EASE_ATTR_REVOKE_MSG_ID, message.getMsgId());
    } else {
        // The local full size pic does not exist yet.
        // ShowBigImage needs to download it from the server
        // first
        intent.putExtra("secret", imgBody.getSecret());
        intent.putExtra("remotepath", imgBody.getRemoteUrl());
        // 这里把当前消息的id传递过去,是为了实现查看大图之后销毁这条消息
        intent.putExtra(EaseConstant.EASE_ATTR_REVOKE_MSG_ID, message.getMsgId());
    }
    if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked
    		&& message.getChatType() == ChatType.Chat) {
        sendACKMessage();
    }
    context.startActivity(intent);
}
 
开发者ID:easemob,项目名称:easeui,代码行数:24,代码来源:EaseChatRowImage.java


示例17: onBubbleClick

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
    String filePath = fileMessageBody.getLocalUrl();
    File file = new File(filePath);
    if (file != null && file.exists()) {
        // 文件存在,直接打开
        FileUtils.openFile(file, (Activity) context);
    } else {
        // 下载
        context.startActivity(new Intent(context, EaseShowNormalFileActivity.class).putExtra("msgbody", message.getBody()));
    }
    if (message.direct == EMMessage.Direct.RECEIVE && !message.isAcked && message.getChatType() == ChatType.Chat) {
        try {
            EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
            message.isAcked = true;
        } catch (EaseMobException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
}
 
开发者ID:easemob,项目名称:easeui,代码行数:23,代码来源:EaseChatRowFile.java


示例18: onBubbleClick

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
    VideoMessageBody videoBody = (VideoMessageBody) message.getBody();
       EMLog.d(TAG, "video view is on click");
       Intent intent = new Intent(context, EaseShowVideoActivity.class);
       intent.putExtra("localpath", videoBody.getLocalUrl());
       intent.putExtra("secret", videoBody.getSecret());
       intent.putExtra("remotepath", videoBody.getRemoteUrl());
       if (message != null && message.direct == EMMessage.Direct.RECEIVE && !message.isAcked
               && message.getChatType() == ChatType.Chat) {
           message.isAcked = true;
           try {
               EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
           } catch (Exception e) {
               e.printStackTrace();
           }
       }
       activity.startActivity(intent);
}
 
开发者ID:easemob,项目名称:easeui,代码行数:20,代码来源:EaseChatRowVideo.java


示例19: sendText

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
/**
 * 发送文本消息
 * 
 * @param content
 *            message content
 * @param isResend
 *            boolean resend
 */
private void sendText(String content) {

	if (content.length() > 0) {
		EMMessage message = EMMessage.createSendMessage(EMMessage.Type.TXT);
		// 如果是群聊,设置chattype,默认是单聊
		if (chatType == CHATTYPE_GROUP)
			message.setChatType(ChatType.GroupChat);
		TextMessageBody txtBody = new TextMessageBody(content);
		// 设置消息body
		message.addBody(txtBody);
		// 设置要发给谁,用户username或者群聊groupid
		message.setReceipt(toChatUsername);
		// 把messgage加到conversation中
		conversation.addMessage(message);
		// 通知adapter有消息变动,adapter会根据加入的这条message显示消息和调用sdk的发送方法
		adapter.refreshSelectLast();
		mEditTextContent.setText("");

		setResult(RESULT_OK);

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


示例20: sendVoice

import com.easemob.chat.EMMessage.ChatType; //导入依赖的package包/类
/**
 * 发送语音
 * 
 * @param filePath
 * @param fileName
 * @param length
 * @param isResend
 */
private void sendVoice(String filePath, String fileName, String length, boolean isResend) {
	if (!(new File(filePath).exists())) {
		return;
	}
	try {
		final EMMessage message = EMMessage.createSendMessage(EMMessage.Type.VOICE);
		// 如果是群聊,设置chattype,默认是单聊
		if (chatType == CHATTYPE_GROUP)
			message.setChatType(ChatType.GroupChat);
		message.setReceipt(toChatUsername);
		int len = Integer.parseInt(length);
		VoiceMessageBody body = new VoiceMessageBody(new File(filePath), len);
		message.addBody(body);

		conversation.addMessage(message);
		adapter.refreshSelectLast();
		setResult(RESULT_OK);
		// send file
		// sendVoiceSub(filePath, fileName, message);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Owater,项目名称:school_shop,代码行数:32,代码来源:ChatActivity.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Seek类代码示例发布时间:2022-05-23
下一篇:
Java AclFeature类代码示例发布时间: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