Java Code Examples for com.easemob.chat.EMMessage#getTo()
The following examples show how to use
com.easemob.chat.EMMessage#getTo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DemoHXSDKHelper.java From school_shop with MIT License | 5 votes |
@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); } } }; }
Example 2
Source File: EaseChatFragment.java From monolog-android with MIT License | 4 votes |
/** * 事件监听,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; } }
Example 3
Source File: MessageAdapter.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
private void sendPictureMessage(final EMMessage message, final ViewHolder holder) { try { String to = message.getTo(); // before send, update ui holder.staus_iv.setVisibility(View.GONE); holder.pb.setVisibility(View.VISIBLE); holder.tv.setVisibility(View.VISIBLE); holder.tv.setText("0%"); final long start = System.currentTimeMillis(); // if (chatType == ChatActivity.CHATTYPE_SINGLE) { EMChatManager.getInstance().sendMessage(message, new EMCallBack() { @Override public void onSuccess() { Log.d(TAG, "send image message successfully"); activity.runOnUiThread(new Runnable() { public void run() { // send success holder.pb.setVisibility(View.GONE); holder.tv.setVisibility(View.GONE); } }); } @Override public void onError(int code, String error) { activity.runOnUiThread(new Runnable() { public void run() { holder.pb.setVisibility(View.GONE); holder.tv.setVisibility(View.GONE); // message.setSendingStatus(Message.SENDING_STATUS_FAIL); holder.staus_iv.setVisibility(View.VISIBLE); Toast.makeText( activity, activity.getString(R.string.send_fail) + activity .getString(R.string.connect_failuer_toast), 0).show(); } }); } @Override public void onProgress(final int progress, String status) { activity.runOnUiThread(new Runnable() { public void run() { holder.tv.setText(progress + "%"); } }); } }); } catch (Exception e) { e.printStackTrace(); } }
Example 4
Source File: MessageAdapter.java From school_shop with MIT License | 4 votes |
private void sendPictureMessage(final EMMessage message, final ViewHolder holder) { try { String to = message.getTo(); // before send, update ui holder.staus_iv.setVisibility(View.GONE); holder.pb.setVisibility(View.VISIBLE); holder.tv.setVisibility(View.VISIBLE); holder.tv.setText("0%"); final long start = System.currentTimeMillis(); // if (chatType == ChatActivity.CHATTYPE_SINGLE) { EMChatManager.getInstance().sendMessage(message, new EMCallBack() { @Override public void onSuccess() { Log.d(TAG, "send image message successfully"); activity.runOnUiThread(new Runnable() { public void run() { // send success holder.pb.setVisibility(View.GONE); holder.tv.setVisibility(View.GONE); } }); } @Override public void onError(int code, String error) { activity.runOnUiThread(new Runnable() { public void run() { holder.pb.setVisibility(View.GONE); holder.tv.setVisibility(View.GONE); // message.setSendingStatus(Message.SENDING_STATUS_FAIL); holder.staus_iv.setVisibility(View.VISIBLE); Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), 0).show(); } }); } @Override public void onProgress(final int progress, String status) { activity.runOnUiThread(new Runnable() { public void run() { holder.tv.setText(progress + "%"); } }); } }); } catch (Exception e) { e.printStackTrace(); } }
Example 5
Source File: ChatActivity.java From school_shop with MIT License | 4 votes |
/** * 事件监听 * * 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; } }