本文整理汇总了Java中com.easemob.chat.EMMessage类的典型用法代码示例。如果您正苦于以下问题:Java EMMessage类的具体用法?Java EMMessage怎么用?Java EMMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMMessage类属于com.easemob.chat包,在下文中一共展示了EMMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: stopPlayVoice
import com.easemob.chat.EMMessage; //导入依赖的package包/类
public void stopPlayVoice() {
voiceAnimation.stop();
if (message.direct == EMMessage.Direct.RECEIVE) {
voiceIconView.setImageResource(R.drawable.chatfrom_voice_playing);
} else {
voiceIconView.setImageResource(R.drawable.chatto_voice_playing);
}
// stop play voice
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
}
isPlaying = false;
((ChatActivity) activity).playMsgId = null;
adapter.notifyDataSetChanged();
}
开发者ID:tengbinlive,项目名称:info_demo,代码行数:17,代码来源:VoicePlayClickListener.java
示例2: sendMsgInBackground
import com.easemob.chat.EMMessage; //导入依赖的package包/类
/**
* 发送消息
*
* @param message
* @param holder
*/
public void sendMsgInBackground(final EMMessage message, final ViewHolder holder) {
holder.staus_iv.setVisibility(View.GONE);
holder.pb.setVisibility(View.VISIBLE);
EMChatManager.getInstance().sendMessage(message, new EMCallBack() {
@Override
public void onSuccess() {
updateSendedView(message, holder);
}
@Override
public void onError(int code, String error) {
updateSendedView(message, holder);
}
@Override
public void onProgress(int progress, String status) {
}
});
}
开发者ID:macyuan,项目名称:TAG,代码行数:29,代码来源:MessageAdapter.java
示例3: doInBackground
import com.easemob.chat.EMMessage; //导入依赖的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
示例4: sendVideo
import com.easemob.chat.EMMessage; //导入依赖的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: onReceive
import com.easemob.chat.EMMessage; //导入依赖的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
示例6: onApplicationAccept
import com.easemob.chat.EMMessage; //导入依赖的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
示例7: sortConversationByLastChatTime
import com.easemob.chat.EMMessage; //导入依赖的package包/类
/**
* 根据最后一条消息的时间排序
*
* @param usernames
*/
private void sortConversationByLastChatTime(List<EMConversation> conversationList) {
Collections.sort(conversationList, new Comparator<EMConversation>() {
@Override
public int compare(final EMConversation con1, final EMConversation con2) {
EMMessage con2LastMessage = con2.getLastMessage();
EMMessage con1LastMessage = con1.getLastMessage();
if (con2LastMessage.getMsgTime() == con1LastMessage.getMsgTime()) {
return 0;
} else if (con2LastMessage.getMsgTime() > con1LastMessage.getMsgTime()) {
return 1;
} else {
return -1;
}
}
});
}
开发者ID:macyuan,项目名称:TAG,代码行数:24,代码来源:ChatAllHistoryFragment.java
示例8: sortUserByLastChatTime
import com.easemob.chat.EMMessage; //导入依赖的package包/类
/**
* 根据最后一条消息的时间排序
*
* @param usernames
*/
private void sortUserByLastChatTime(List<EMContact> contactList) {
Collections.sort(contactList, new Comparator<EMContact>() {
@Override
public int compare(final EMContact user1, final EMContact user2) {
EMConversation conversation1 = EMChatManager.getInstance().getConversation(user1.getUsername());
EMConversation conversation2 = EMChatManager.getInstance().getConversation(user2.getUsername());
EMMessage user2LastMessage = conversation2.getLastMessage();
EMMessage user1LastMessage = conversation1.getLastMessage();
if (user2LastMessage.getMsgTime() == user1LastMessage.getMsgTime()) {
return 0;
} else if (user2LastMessage.getMsgTime() > user1LastMessage.getMsgTime()) {
return 1;
} else {
return -1;
}
}
});
}
开发者ID:macyuan,项目名称:TAG,代码行数:26,代码来源:ChatHistoryFragment.java
示例9: onSendTxtMsg
import com.easemob.chat.EMMessage; //导入依赖的package包/类
/****
*
* @param view
*/
public void onSendTxtMsg(String content) {
try {
//创建一个消息
EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.TXT);
//设置消息的接收方
msg.setReceipt("bot");
//设置消息内容。本消息类型为文本消息。
msg.addBody(new TextMessageBody("我正在浏览你的主页"));
//发送消息
EMChatManager.getInstance().sendMessage(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:macyuan,项目名称:TAG,代码行数:21,代码来源:Userinfo.java
示例10: doInBackground
import com.easemob.chat.EMMessage; //导入依赖的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
示例11: registerEaseMobEventListener
import com.easemob.chat.EMMessage; //导入依赖的package包/类
/**
* 全局事件监听
* 这里是拿来获取用户资料和未读计数的
*/
protected void registerEaseMobEventListener() {
EMChatManager.getInstance().registerEventListener(new EMEventListener() {
@Override
public void onEvent(EMNotifierEvent event) {
final EMMessage msg = (EMMessage) event.getData();
if (event.getEvent() == EMNotifierEvent.Event.EventNewMessage) {
//未在聊天的任何界面就计数
if (!EaseUI.getInstance().hasForegroundActivies()) {
PrefService.getInstance(mContext).increatUnread();
Log.d(TAG, "new Msg Count");
}
//更新联系人
asyncContact(msg);
//广播通知,主界面拿来更新的
Intent broadcastIntent = new Intent(MsgReceiver.NEW_MSG_BROADCAST);
mContext.sendBroadcast(broadcastIntent, null);
}
}
});
}
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:29,代码来源:EaseMobService.java
示例12: onNewMesg
import com.easemob.chat.EMMessage; //导入依赖的package包/类
public synchronized void onNewMesg(List<EMMessage> messages) {
if(EMChatManager.getInstance().isSlientMessage(messages.get(messages.size()-1))){
return;
}
EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider();
if(!settingsProvider.isMsgNotifyAllowed(null)){
return;
}
// 判断app是否在后台
if (!EasyUtils.isAppRunningForeground(appContext)) {
EMLog.d(TAG, "app is running in backgroud");
sendNotification(messages, false);
} else {
sendNotification(messages, true);
}
viberateAndPlayTone(messages.get(messages.size()-1));
}
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:18,代码来源:EaseNotifier.java
示例13: onConversationInit
import com.easemob.chat.EMMessage; //导入依赖的package包/类
protected void onConversationInit(){
// 获取当前conversation对象
conversation = EMChatManager.getInstance().getConversation(toChatUsername);
// 把此会话的未读数置为0
conversation.markAllMessagesAsRead();
// 初始化db时,每个conversation加载数目是getChatOptions().getNumberOfMessagesLoaded
// 这个数目如果比用户期望进入会话界面时显示的个数不一样,就多加载一些
final List<EMMessage> msgs = conversation.getAllMessages();
int msgCount = msgs != null ? msgs.size() : 0;
if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) {
String msgId = null;
if (msgs != null && msgs.size() > 0) {
msgId = msgs.get(0).getMsgId();
}
if (chatType == EaseConstant.CHATTYPE_SINGLE) {
conversation.loadMoreMsgFromDB(msgId, pagesize - msgCount);
} else {
conversation.loadMoreGroupMsgFromDB(msgId, pagesize - msgCount);
}
}
}
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:26,代码来源:EaseChatFragment.java
示例14: stopPlayVoice
import com.easemob.chat.EMMessage; //导入依赖的package包/类
public void stopPlayVoice() {
voiceAnimation.stop();
if (message.direct == EMMessage.Direct.RECEIVE) {
voiceIconView.setImageResource(R.drawable.ease_chatfrom_voice_playing);
} else {
voiceIconView.setImageResource(R.drawable.ease_chatto_voice_playing);
}
// stop play voice
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
}
isPlaying = false;
playMsgId = null;
adapter.notifyDataSetChanged();
}
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:17,代码来源:EaseChatRowVoicePlayClickListener.java
示例15: sendMessage
import com.easemob.chat.EMMessage; //导入依赖的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
示例16: onSetUpView
import com.easemob.chat.EMMessage; //导入依赖的package包/类
@Override
protected void onSetUpView() {
fileMessageBody = (NormalFileMessageBody) message.getBody();
String filePath = fileMessageBody.getLocalUrl();
fileNameView.setText(fileMessageBody.getFileName());
fileSizeView.setText(TextFormater.getDataSize(fileMessageBody.getFileSize()));
if (message.direct == EMMessage.Direct.RECEIVE) { // 接收的消息
File file = new File(filePath);
if (file != null && file.exists()) {
fileStateView.setText(R.string.Have_downloaded);
} else {
fileStateView.setText(R.string.Did_not_download);
}
return;
}
// until here, deal with send voice msg
handleSendMessage();
}
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:20,代码来源:EaseChatRowFile.java
示例17: getMessageDigest
import com.easemob.chat.EMMessage; //导入依赖的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
示例18: VoicePlayClickListener
import com.easemob.chat.EMMessage; //导入依赖的package包/类
/**
*
* @param message
* @param v
* @param iv_read_status
* @param context
* @param activity
* @param user
* @param chatType
*/
public VoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity activity,
String username) {
this.message = message;
voiceBody = (VoiceMessageBody) message.getBody();
this.iv_read_status = iv_read_status;
this.adapter=adapter;
voiceIconView = v;
this.activity = activity;
this.username = username;
this.chatType = message.getChatType();
}
开发者ID:macyuan,项目名称:TAG,代码行数:22,代码来源:VoicePlayClickListener.java
示例19: showAnimation
import com.easemob.chat.EMMessage; //导入依赖的package包/类
private void showAnimation() {
// play voice, and start animation
if (message.direct == EMMessage.Direct.RECEIVE) {
voiceIconView.setImageResource(R.anim.voice_from_icon);
} else {
voiceIconView.setImageResource(R.anim.voice_to_icon);
}
voiceAnimation = (AnimationDrawable) voiceIconView.getDrawable();
voiceAnimation.start();
}
开发者ID:macyuan,项目名称:TAG,代码行数:11,代码来源:VoicePlayClickListener.java
示例20: getItemViewType
import com.easemob.chat.EMMessage; //导入依赖的package包/类
public int getItemViewType(int position) {
EMMessage message = conversation.getMessage(position);
//String attr = message.getStringAttribute("attr",null);//获取扩展属性
if (message.getType() == EMMessage.Type.TXT) {
/*if(!CommonUtils.isNullOrEmpty(attr)){//判断扩展属性是否为空
if(attr.equals("card")){//判断扩展属性是否是名片
return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
}
}*/
return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_TXT : MESSAGE_TYPE_SENT_TXT;
}
if (message.getType() == EMMessage.Type.IMAGE) {
return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_IMAGE : MESSAGE_TYPE_SENT_IMAGE;
}
if (message.getType() == EMMessage.Type.LOCATION) {
return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_LOCATION : MESSAGE_TYPE_SENT_LOCATION;
}
if (message.getType() == EMMessage.Type.VOICE) {
return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VOICE : MESSAGE_TYPE_SENT_VOICE;
}
if (message.getType() == EMMessage.Type.VIDEO) {
return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_VIDEO : MESSAGE_TYPE_SENT_VIDEO;
}
if (message.getType() == EMMessage.Type.FILE) {
return message.direct == EMMessage.Direct.RECEIVE ? MESSAGE_TYPE_RECV_FILE : MESSAGE_TYPE_SENT_FILE;
}
return -1;// invalid
}
开发者ID:macyuan,项目名称:TAG,代码行数:31,代码来源:MessageAdapter.java
注:本文中的com.easemob.chat.EMMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论