Ejemplo n.º 1
0
 private static void showNotification(ECMessage msg) {
   if (checkNeedNotification(msg.getSessionId())) {
     ECNotificationManager.getInstance().forceCancelNotification();
     String lastMsg = "";
     if (msg.getType() == ECMessage.Type.TXT) {
       lastMsg = ((ECTextMessageBody) msg.getBody()).getMessage();
     }
     ECContacts contact = ContactSqlManager.getContact(msg.getForm());
     if (contact == null) {
       return;
     }
     ECNotificationManager.getInstance()
         .showCustomNewMessageNotification(
             CCPAppManager.getContext(),
             lastMsg,
             contact.getNickname(),
             msg.getSessionId(),
             msg.getType().ordinal());
   }
 }
Ejemplo n.º 2
0
 @Override
 public void onReceiveOfflineMessageCompletion() {
   if (mOfflineMsg == null) {
     return;
   }
   // SDK离线消息拉取完成之后会通过该接口通知应用
   // 应用可以在此做类似于Loading框的关闭,Notification通知等等
   // 如果已经没有需要同步消息的请求时候,则状态栏开始提醒
   ECMessage lastECMessage = mOfflineMsg;
   try {
     if (lastECMessage != null && mHistoryMsgCount > 0 && isFirstSync) {
       showNotification(lastECMessage);
       // lastECMessage.setSessionId(lastECMessage.getTo().startsWith("G")?lastECMessage.getTo():lastECMessage.getForm());
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   isFirstSync = isSyncOffline = false;
   // 无需要同步的消息
   CCPAppManager.getContext().sendBroadcast(new Intent(INTENT_ACTION_SYNC_MESSAGE));
   mOfflineMsg = null;
 }
Ejemplo n.º 3
0
 @Override
 public void onSendMessageComplete(ECError error, ECMessage message) {
   if (message == null) {
     return;
   }
   // 处理ECMessage的发送状态
   if (message != null) {
     if (message.getType() == ECMessage.Type.VOICE) {
       try {
         DemoUtils.playNotifycationMusic(
             CCPAppManager.getContext(), "sound/voice_message_sent.mp3");
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
     IMessageSqlManager.setIMessageSendStatus(
         message.getMsgId(), message.getMsgStatus().ordinal());
     IMessageSqlManager.notifyMsgChanged(message.getSessionId());
     if (mOnMessageReportCallback != null) {
       mOnMessageReportCallback.onMessageReport(error, message);
     }
     return;
   }
 }