Esempio n. 1
0
  private synchronized void postReceiveMessage(ECMessage ecMessage, boolean showNotice) {
    int userId = Integer.parseInt(ecMessage.getSessionId());
    Friend friend = FriendCache.getInstance(mContext).getFriend(userId);
    String message = ((ECTextMessageBody) ecMessage.getBody()).getMessage();
    History history = new History(message, userId, mContext);
    HistoryCache.getInstance(mContext).updateHistory(history, friend);
    ConversationCache.getInstance()
        .updateConversation(
            new Conversation(
                userId,
                String.format(mContext.getString(R.string.send_bomb_message), history.getTime())));
    if (history.getStatus() == History.accepted) {
      AlarmSetManager.setAlarm(mContext, history, friend);
    } else if (history.getStatus() == History.failed) {
      AlarmHelper.getInstance(mContext).stopAudio();
    }
    LogUtil.d(TAG, ecMessage.getBody().toString());
    if (mOnMessageReportCallback != null) {
      ArrayList<ECMessage> messages = new ArrayList<>();
      messages.add(ecMessage);
      mOnMessageReportCallback.onPushMessage();
    }

    // 是否状态栏提示
    if (showNotice) showNotification(ecMessage);
  }
Esempio n. 2
0
  private void showNotification(ECMessage ecMessage) {
    CallUpNotificationManager.getInstance().forceCancelNotification();

    int userId = Integer.parseInt(ecMessage.getForm());
    Friend friend = FriendCache.getInstance(mContext).getFriend(userId);
    if (friend == null) {
      return;
    }

    CallUpNotificationManager.getInstance()
        .showCustomNewMessageNotification(
            BaseInfoUtil.getContext(),
            friend,
            ecMessage.getSessionId(),
            ecMessage.getType().ordinal());
  }