本文整理汇总了Java中com.hyphenate.chat.EMMessage类的典型用法代码示例。如果您正苦于以下问题:Java EMMessage类的具体用法?Java EMMessage怎么用?Java EMMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMMessage类属于com.hyphenate.chat包,在下文中一共展示了EMMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendAtMessage
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
/**
* send @ message, only support group chat message
* @param content
*/
@SuppressWarnings("ConstantConditions")
private void sendAtMessage(String content){
if(chatType != EaseConstant.CHATTYPE_GROUP){
EMLog.e(TAG, "only support group chat message");
return;
}
EMMessage message = EMMessage.createTxtSendMessage(content, toChatUsername);
EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
if(EMClient.getInstance().getCurrentUser().equals(group.getOwner()) && EaseAtMessageHelper.get().containsAtAll(content)){
message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL);
}else {
message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG,
EaseAtMessageHelper.get().atListToJsonArray(EaseAtMessageHelper.get().getAtMessageUsernames(content)));
}
sendMessage(message);
}
示例2: isAtMeMsg
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
public boolean isAtMeMsg(EMMessage message){
EaseUser user = EaseUserUtils.getUserInfo(message.getFrom());
if(user != null){
try {
JSONArray jsonArray = message.getJSONArrayAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG);
for(int i = 0; i < jsonArray.length(); i++){
String username = jsonArray.getString(i);
if(username.equals(EMClient.getInstance().getCurrentUser())){
return true;
}
}
} catch (Exception e) {
//perhaps is a @ all message
String atUsername = message.getStringAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, null);
if(atUsername != null){
if(atUsername.toUpperCase().equals(EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL)){
return true;
}
}
return false;
}
}
return false;
}
示例3: sendMessage
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
protected void sendMessage(EMMessage message){
if (message == null) {
return;
}
if(chatFragmentHelper != null){
//set extension
chatFragmentHelper.onSetMessageAttributes(message);
}
if (chatType == EaseConstant.CHATTYPE_GROUP){
message.setChatType(ChatType.GroupChat);
}else if(chatType == EaseConstant.CHATTYPE_CHATROOM){
message.setChatType(ChatType.ChatRoom);
}
//send message
EMClient.getInstance().chatManager().sendMessage(message);
//refresh ui
if(isMessageListInited) {
messageList.refreshSelectLast();
}
}
示例4: onConversationInit
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
protected void onConversationInit(){
conversation = EMClient.getInstance().chatManager().getConversation(toChatUsername, EaseCommonUtils.getConversationType(chatType), true);
conversation.markAllMessagesAsRead();
// the number of messages loaded into conversation is getChatOptions().getNumberOfMessagesLoaded
// you can change this number
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();
}
conversation.loadMoreMsgFromDB(msgId, pagesize - msgCount);
}
}
示例5: onMessageReceived
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(List<EMMessage> messages) {
for (EMMessage message : messages) {
String username = null;
// group message
if (message.getChatType() == ChatType.GroupChat || message.getChatType() == ChatType.ChatRoom) {
username = message.getTo();
} else {
// single chat message
username = message.getFrom();
}
// if the message is for current conversation
if (username.equals(toChatUsername) || message.getTo().equals(toChatUsername)) {
messageList.refreshSelectLast();
EaseUI.getInstance().getNotifier().vibrateAndPlayTone(message);
conversation.markMessageAsRead(message.getMsgId());
} else {
EaseUI.getInstance().getNotifier().onNewMsg(message);
}
}
}
示例6: onBubbleClick
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
String filePath = fileMessageBody.getLocalUrl();
File file = new File(filePath);
if (file.exists()) {
// open files if it exist
FileUtils.openFile(file, (Activity) context);
} else {
// download the file
context.startActivity(new Intent(context, EaseShowNormalFileActivity.class).putExtra("msg", message));
}
if (message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == ChatType.Chat) {
try {
EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (HyphenateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
示例7: onSetUpView
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
protected void onSetUpView() {
fileMessageBody = (EMNormalFileMessageBody) 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.exists()) {
fileStateView.setText(R.string.Have_downloaded);
} else {
fileStateView.setText(R.string.Did_not_download);
}
return;
}
// until here, to sending message
handleSendMessage();
}
示例8: onBubbleClick
import com.hyphenate.chat.EMMessage; //导入依赖的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
String msgId = message.getMsgId();
intent.putExtra("messageId", msgId);
intent.putExtra("localUrl", imgBody.getLocalUrl());
}
if (message != null && message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked()
&& message.getChatType() == ChatType.Chat) {
try {
EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (Exception e) {
e.printStackTrace();
}
}
context.startActivity(intent);
}
示例9: stopPlayVoice
import com.hyphenate.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();
}
示例10: onNewMesg
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
public synchronized void onNewMesg(List<EMMessage> messages) {
if(EaseCommonUtils.isSilentMessage(messages.get(messages.size()-1))){
return;
}
EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider();
if(!settingsProvider.isMsgNotifyAllowed(null)){
return;
}
// check if app running background
if (!EasyUtils.isAppRunningForeground(appContext)) {
EMLog.d(TAG, "app is running in backgroud");
sendNotification(messages, false);
} else {
sendNotification(messages, true);
}
vibrateAndPlayTone(messages.get(messages.size()-1));
}
示例11: onBubbleClick
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
protected void onBubbleClick() {
EMVideoMessageBody videoBody = (EMVideoMessageBody) message.getBody();
EMLog.d(TAG, "video view is on click");
Intent intent = new Intent(context, EaseShowVideoActivity.class);
intent.putExtra("msg", message);
if (message != null && message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked()
&& message.getChatType() == ChatType.Chat) {
try {
EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (Exception e) {
e.printStackTrace();
}
}
activity.startActivity(intent);
}
示例12: onMessageReceived
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
public void onMessageReceived(List<EMMessage> messages) {
for (EMMessage message : messages) {
String username = null;
// group message
if (message.getChatType() == EMMessage.ChatType.GroupChat || message.getChatType() == EMMessage.ChatType.ChatRoom) {
username = message.getTo();
} else {
// single chat message
username = message.getFrom();
}
// if the message is for current conversation
if (username.equals(toChatUsername) || message.getTo().equals(toChatUsername) || message.conversationId().equals(toChatUsername)) {
messageList.refreshSelectLast();
EaseUI.getInstance().getNotifier().vibrateAndPlayTone(message);
conversation.markMessageAsRead(message.getMsgId());
} else {
EaseUI.getInstance().getNotifier().onNewMsg(message);
}
}
}
示例13: sendMessage
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
public void sendMessage(final String userName, final String message) {
ThreadUtils.runOnBackgroundThread(new Runnable() {
@Override
public void run() {
EMMessage emMessage = EMMessage.createTxtSendMessage(message, userName);
emMessage.setStatus(EMMessage.Status.INPROGRESS);
emMessage.setMessageStatusCallback(mEMCallBackAdapter);
mEMMessageList.add(emMessage);
EMClient.getInstance().chatManager().sendMessage(emMessage);
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
mChatView.onStartSendMessage();
}
});
}
});
}
示例14: createExpressionMessage
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
public static EMMessage createExpressionMessage(String toChatUsername, String expressioName, String identityCode){
EMMessage message = EMMessage.createTxtSendMessage("["+expressioName+"]", toChatUsername);
if(identityCode != null){
message.setAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, identityCode);
}
message.setAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, true);
return message;
}
示例15: onInflateView
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
protected void onInflateView() {
int redType = getTypeOfred(message);
switch (redType) {
case 0:
inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ?
R.layout.ease_row_received_message : R.layout.ease_row_sent_message, this);
break;
case 1:
inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ?
R.layout.ease_row_received_message_resendmoney : R.layout.ease_row_sent_message_resendmoney, this);
break;
case 2:
inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ?
R.layout.ease_row_received_message_sendmoney : R.layout.ease_row_sent_message_sendmoney, this);
break;
case 3:
inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ?
R.layout.ease_row_received_message_repacket : R.layout.ease_row_sent_message_repacket, this);
break;
case 4:
inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ?
R.layout.ease_row_received_message_repacket : R.layout.ease_row_sent_message_repacket, this);
// inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ?
// R.layout.ease_row_received_message : R.layout.ease_row_sent_message, this);
break;
}
}