本文整理汇总了Java中com.easemob.chat.EMMessage.ChatType.GroupChat方法的典型用法代码示例。如果您正苦于以下问题:Java ChatType.GroupChat方法的具体用法?Java ChatType.GroupChat怎么用?Java ChatType.GroupChat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.easemob.chat.EMMessage.ChatType
的用法示例。
在下文中一共展示了ChatType.GroupChat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: onEvent
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
/**
* 事件监听,registerEventListener后的回调事件
*
* see {@link EMNotifierEvent}
*/
@Override
public void onEvent(EMNotifierEvent event) {
switch (event.getEvent()) {
case EventNewMessage:
// 获取到message
EMMessage message = (EMMessage) event.getData();
String username = null;
// 群组消息
if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
username = message.getTo();
} else {
// 单聊消息
username = message.getFrom();
}
// 如果是当前会话的消息,刷新聊天页面
if (username.equals(toChatUsername)) {
messageList.refreshSelectLast();
// 声音和震动提示有新消息
EaseUI.getInstance().getNotifier().viberateAndPlayTone(message);
} else {
// 如果消息不是和当前聊天ID的消息
EaseUI.getInstance().getNotifier().onNewMsg(message);
}
break;
case EventDeliveryAck:
case EventReadAck:
// 获取到message
messageList.refresh();
break;
case EventOfflineMessage:
// a list of offline messages
// List<EMMessage> offlineMessages = (List<EMMessage>)
// event.getData();
messageList.refresh();
break;
default:
break;
}
}
示例6: onEvent
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
/**
* 事件监听,registerEventListener后的回调事件
*
* see {@link EMNotifierEvent}
*/
@Override
public void onEvent(EMNotifierEvent event) {
switch (event.getEvent()) {
case EventNewMessage:
// 获取到message
EMMessage message = (EMMessage) event.getData();
String username = null;
// 群组消息
if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
username = message.getTo();
} else {
// 单聊消息
username = message.getFrom();
}
// 如果是当前会话的消息,刷新聊天页面
if (username.equals(toChatUsername)) {
messageList.refreshSelectLast();
// 声音和震动提示有新消息
EaseUI.getInstance().getNotifier().viberateAndPlayTone(message);
} else {
// 如果消息不是和当前聊天ID的消息
EaseUI.getInstance().getNotifier().onNewMsg(message);
}
break;
case EventDeliveryAck:
case EventReadAck:
// 获取到message
EMMessage ackMessage = (EMMessage) event.getData();
// 判断接收到ack的这条消息是不是阅后即焚的消息,如果是,则说明对方看过消息了,对方会销毁,这边也删除(现在只有txt iamge file三种消息支持 )
if(ackMessage.getBooleanAttribute(EaseConstant.EASE_ATTR_READFIRE, false)
&& (ackMessage.getType() == Type.TXT || ackMessage.getType() == Type.VOICE || ackMessage.getType() == Type.IMAGE)){
conversation.removeMessage(ackMessage.getMsgId());
}
messageList.refresh();
break;
case EventOfflineMessage:
// a list of offline messages
// List<EMMessage> offlineMessages = (List<EMMessage>)
// event.getData();
messageList.refresh();
break;
case EventNewCMDMessage:
EMMessage cmdMessage = (EMMessage) event.getData();
//获取消息body
CmdMessageBody cmdMsgBody = (CmdMessageBody) cmdMessage.getBody();
final String action = cmdMsgBody.action;//获取自定义action
if(action.equals(EaseConstant.EASE_ATTR_REVOKE)){
EaseCommonUtils.receiveRevokeMessage(getActivity(), cmdMessage);
messageList.refresh();
}
break;
default:
break;
}
}
示例7: onEvent
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
/**
* 事件监听
*
* see {@link EMNotifierEvent}
*/
@Override
public void onEvent(EMNotifierEvent event) {
switch (event.getEvent()) {
case EventNewMessage:
{
//获取到message
EMMessage message = (EMMessage) event.getData();
String username = null;
//群组消息
if(message.getChatType() == ChatType.GroupChat){
username = message.getTo();
}
else{
//单聊消息
username = message.getFrom();
}
//如果是当前会话的消息,刷新聊天页面
if(username.equals(getToChatUsername())){
refreshUIWithNewMessage();
//声音和震动提示有新消息
HXSDKHelper.getInstance().getNotifier().viberateAndPlayTone(message);
}else{
//如果消息不是和当前聊天ID的消息
HXSDKHelper.getInstance().getNotifier().onNewMsg(message);
}
break;
}
// case EventDeliveryAck:
// {
// //获取到message
// EMMessage message = (EMMessage) event.getData();
// refreshUI();
// break;
// }
// case EventReadAck:
// {
// //获取到message
// EMMessage message = (EMMessage) event.getData();
// refreshUI();
// break;
// }
case EventOfflineMessage:
{
//a list of offline messages
//List<EMMessage> offlineMessages = (List<EMMessage>) event.getData();
refreshUI();
break;
}
default:
break;
}
}
示例8: onEvent
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
/**
* 事件监听,registerEventListener后的回调事件
* <p/>
* see {@link EMNotifierEvent}
*/
@Override
public void onEvent(EMNotifierEvent event) {
switch (event.getEvent()) {
case EventNewMessage:
// 获取到message
EMMessage message = (EMMessage) event.getData();
String username = null;
// 群组消息
if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
username = message.getTo();
} else {
// 单聊消息
username = message.getFrom();
}
// 如果是当前会话的消息,刷新聊天页面
if (username.equals(toChatUsername)) {
messageList.refreshSelectLast();
// 声音和震动提示有新消息
EaseUI.getInstance().getNotifier().viberateAndPlayTone(message);
} else {
// 如果消息不是和当前聊天ID的消息
EaseUI.getInstance().getNotifier().onNewMsg(message);
}
break;
case EventDeliveryAck:
case EventReadAck:
// 获取到message
messageList.refresh();
break;
case EventOfflineMessage:
// a list of offline messages
// List<EMMessage> offlineMessages = (List<EMMessage>)
// event.getData();
messageList.refresh();
break;
default:
break;
}
}