本文整理汇总了Java中com.easemob.chat.EMMessage.ChatType.Chat方法的典型用法代码示例。如果您正苦于以下问题:Java ChatType.Chat方法的具体用法?Java ChatType.Chat怎么用?Java ChatType.Chat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.easemob.chat.EMMessage.ChatType
的用法示例。
在下文中一共展示了ChatType.Chat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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();
}
}
}
示例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.Chat) {
message.isAcked = true;
try {
EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (Exception e) {
e.printStackTrace();
}
}
activity.startActivity(intent);
}
示例4: onSetUpView
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
@Override
protected void onSetUpView() {
locBody = (LocationMessageBody) message.getBody();
locationView.setText(locBody.getAddress());
// deal with send message
if (message.direct == EMMessage.Direct.SEND) {
setMessageSendCallback();
switch (message.status) {
case CREATE:
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
break;
case SUCCESS: // 发送成功
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.GONE);
break;
case FAIL: // 发送失败
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
break;
case INPROGRESS: // 发送中
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
break;
default:
break;
}
}else{
if(!message.isAcked() && message.getChatType() == ChatType.Chat){
try {
EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
message.isAcked = true;
} catch (EaseMobException e) {
e.printStackTrace();
}
}
}
}
示例5: handleTextMessage
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
protected void handleTextMessage() {
if (message.direct == EMMessage.Direct.SEND) {
setMessageSendCallback();
switch (message.status) {
case CREATE:
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
// 发送消息
// sendMsgInBackground(message);
break;
case SUCCESS: // 发送成功
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.GONE);
break;
case FAIL: // 发送失败
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
break;
case INPROGRESS: // 发送中
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
break;
default:
break;
}
} else {
if (!message.isAcked() && message.getChatType() == ChatType.Chat
&& !message.getBooleanAttribute(EaseConstant.EASE_ATTR_READFIRE, false)) {
try {
EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
message.isAcked = true;
} catch (EaseMobException e) {
e.printStackTrace();
}
}
}
}
示例6: createNotifier
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
@Override
public HXNotifier createNotifier(){
return new HXNotifier(){
public synchronized void onNewMsg(final EMMessage message) {
if(EMChatManager.getInstance().isSlientMessage(message)){
return;
}
String chatUsename = null;
List<String> notNotifyIds = null;
// 获取设置的不提示新消息的用户或者群组ids
if (message.getChatType() == ChatType.Chat) {
chatUsename = message.getFrom();
notNotifyIds = ((DemoHXSDKModel) hxModel).getDisabledGroups();
} else {
chatUsename = message.getTo();
notNotifyIds = ((DemoHXSDKModel) hxModel).getDisabledIds();
}
if (notNotifyIds == null || !notNotifyIds.contains(chatUsename)) {
// 判断app是否在后台
if (!EasyUtils.isAppRunningForeground(appContext)) {
EMLog.d(TAG, "app is running in backgroud");
sendNotification(message, false);
} else {
sendNotification(message, true);
}
viberateAndPlayTone(message);
}
}
};
}
示例7: handleTextMessage
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
protected void handleTextMessage() {
if (message.direct == EMMessage.Direct.SEND) {
setMessageSendCallback();
switch (message.status) {
case CREATE:
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
// 发送消息
// sendMsgInBackground(message);
break;
case SUCCESS: // 发送成功
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.GONE);
break;
case FAIL: // 发送失败
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
break;
case INPROGRESS: // 发送中
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
break;
default:
break;
}
} else {
if (!message.isAcked() && message.getChatType() == ChatType.Chat) {
try {
EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
message.isAcked = true;
} catch (EaseMobException e) {
e.printStackTrace();
}
}
}
}
示例8: onSetUpView
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
@Override
public void onSetUpView() {
TextMessageBody txtBody = (TextMessageBody) message.getBody();
Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
// 设置内容
contentView.setText(span, BufferType.SPANNABLE);
if (message.direct == EMMessage.Direct.SEND) {
setMessageSendCallback();
switch (message.status) {
case CREATE:
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
// 发送消息
// sendMsgInBackground(message);
break;
case SUCCESS: // 发送成功
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.GONE);
break;
case FAIL: // 发送失败
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
break;
case INPROGRESS: // 发送中
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
break;
default:
break;
}
}else{
if(!message.isAcked() && message.getChatType() == ChatType.Chat){
try {
EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
message.isAcked = true;
} catch (EaseMobException e) {
e.printStackTrace();
}
}
}
}
示例9: onEvent
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
/**
* 监听事件
*/
@Override
public void onEvent(EMNotifierEvent event) {
switch (event.getEvent()) {
case EventNewMessage: // 普通消息
EMMessage message = (EMMessage) event.getData();
// 提示新消息
DemoHelper.getInstance().getNotifier().onNewMsg(message);
refreshUIWithMessage();
break;
case EventOfflineMessage: {
refreshUIWithMessage();
break;
}
case EventConversationListChanged: {
refreshUIWithMessage();
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(this, cmdMessage);
}
refreshUIWithMessage();
break;
case EventReadAck:
// TODO 这里当此消息未加载到内存中时,ackMessage会为null,消息的删除会失败
EMMessage ackMessage = (EMMessage) event.getData();
EMConversation conversation = EMChatManager.getInstance().getConversation(ackMessage.getTo());
// 判断接收到ack的这条消息是不是阅后即焚的消息,如果是,则说明对方看过消息了,对方会销毁,这边也删除(现在只有txt iamge file三种消息支持 )
if(ackMessage.getBooleanAttribute(EaseConstant.EASE_ATTR_READFIRE, false)
&& (ackMessage.getType() == Type.TXT
|| ackMessage.getType() == Type.VOICE
|| ackMessage.getType() == Type.IMAGE)){
// 判断当前会话是不是只有一条消息,如果只有一条消息,并且这条消息也是阅后即焚类型,当对方阅读后,这边要删除,会话会被过滤掉,因此要加载上一条消息
if(conversation.getAllMessages().size() == 1 && conversation.getLastMessage().getMsgId().equals(ackMessage.getMsgId())){
if (ackMessage.getChatType() == ChatType.Chat) {
conversation.loadMoreMsgFromDB(ackMessage.getMsgId(), 1);
} else {
conversation.loadMoreGroupMsgFromDB(ackMessage.getMsgId(), 1);
}
}
conversation.removeMessage(ackMessage.getMsgId());
}
refreshUIWithMessage();
break;
default:
break;
}
}
示例10: onSetUpView
import com.easemob.chat.EMMessage.ChatType; //导入方法依赖的package包/类
@Override
protected void onSetUpView() {
locBody = (LocationMessageBody) message.getBody();
locationView.setText(locBody.getAddress());
// deal with send message
if (message.direct == EMMessage.Direct.SEND) {
setMessageSendCallback();
switch (message.status) {
case CREATE:
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
// 发送消息
// sendMsgInBackground(message);
break;
case SUCCESS: // 发送成功
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.GONE);
break;
case FAIL: // 发送失败
progressBar.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);
break;
case INPROGRESS: // 发送中
progressBar.setVisibility(View.VISIBLE);
statusView.setVisibility(View.GONE);
break;
default:
break;
}
} else {
if (!message.isAcked() && message.getChatType() == ChatType.Chat) {
try {
EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId());
message.isAcked = true;
} catch (EaseMobException e) {
e.printStackTrace();
}
}
}
}