本文整理汇总了Java中com.hyphenate.chat.EMMessage类的典型用法代码示例。如果您正苦于以下问题:Java EMMessage类的具体用法?Java EMMessage怎么用?Java EMMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMMessage类属于com.hyphenate.chat包,在下文中一共展示了EMMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:22,代码来源:EaseChatFragment.java
示例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;
}
开发者ID:turoDog,项目名称:KTalk,代码行数:27,代码来源:EaseAtMessageHelper.java
示例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();
}
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:21,代码来源:EaseChatFragment.java
示例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);
}
}
开发者ID:turoDog,项目名称:KTalk,代码行数:17,代码来源:EaseChatFragment.java
示例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);
}
}
}
开发者ID:turoDog,项目名称:KTalk,代码行数:23,代码来源:EaseChatFragment.java
示例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();
}
}
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:22,代码来源:EaseChatRowFile.java
示例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();
}
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:20,代码来源:EaseChatRowFile.java
示例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);
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:26,代码来源:EaseChatRowImage.java
示例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();
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:17,代码来源:EaseChatRowVoicePlayClickListener.java
示例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));
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:18,代码来源:EaseNotifier.java
示例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);
}
开发者ID:turoDog,项目名称:KTalk,代码行数:17,代码来源:EaseChatRowVideo.java
示例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);
}
}
}
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:23,代码来源:EaseChatFragment.java
示例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();
}
});
}
});
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:20,代码来源:ChatPresenterImpl.java
示例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;
}
开发者ID:turoDog,项目名称:KTalk,代码行数:9,代码来源:EaseCommonUtils.java
示例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;
}
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:39,代码来源:EaseChatRowText.java
示例16: handleTextMessage
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
protected void handleTextMessage() {
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 {
EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
} catch (HyphenateException e) {
e.printStackTrace();
}
}
}
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:34,代码来源:EaseChatRowSendMoney.java
示例17: refreshList
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
private void refreshList() {
// you should not call getAllMessages() in UI thread
// otherwise there is problem when refreshing UI and there is new message arrive
java.util.List<EMMessage> var = conversation.getAllMessages();
messages = var.toArray(new EMMessage[var.size()]);
conversation.markAllMessagesAsRead();
notifyDataSetChanged();
}
开发者ID:turoDog,项目名称:KTalk,代码行数:9,代码来源:EaseMessageAdapter.java
示例18: loadMoreMessages
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
@Override
public void loadMoreMessages(final String userName) {
if (hasMoreData) {
ThreadUtils.runOnBackgroundThread(new Runnable() {
@Override
public void run() {
EMConversation conversation = EMClient.getInstance().chatManager().getConversation(userName);
EMMessage firstMessage = mEMMessageList.get(0);
//SDK初始化加载的聊天记录为20条,到顶时需要去DB里获取更多
//获取startMsgId之前的pagesize条消息,此方法获取的messages SDK会自动存入到此会话中,APP中无需再次把获取到的messages添加到会话中
final List<EMMessage> messages = conversation.loadMoreMsgFromDB(firstMessage.getMsgId(), DEFAULT_PAGE_SIZE);
//当聊天记录超过20条就不再支持刷新
hasMoreData = (messages.size() == DEFAULT_PAGE_SIZE);
mEMMessageList.addAll(0, messages);
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
mChatView.onMoreMessagesLoaded(messages.size());
}
});
}
});
} else {
mChatView.onNoMoreData();
hasMoreData = true;
}
}
开发者ID:Vicent9920,项目名称:FanChat,代码行数:28,代码来源:ChatPresenterImpl.java
示例19: updateView
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
protected void updateView() {
activity.runOnUiThread(new Runnable() {
public void run() {
if (message.status() == EMMessage.Status.FAIL) {
Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), Toast.LENGTH_SHORT).show();
}
onUpdateView();
}
});
}
开发者ID:mangestudio,项目名称:GCSApp,代码行数:12,代码来源:EaseChatRow.java
示例20: updateView
import com.hyphenate.chat.EMMessage; //导入依赖的package包/类
protected void updateView() {
activity.runOnUiThread(new Runnable() {
public void run() {
if (message.status() == EMMessage.Status.FAIL) {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), Toast.LENGTH_SHORT).show();
}
onUpdateView();
}
});
}
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:12,代码来源:EaseChatRow.java
注:本文中的com.hyphenate.chat.EMMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论