Пример #1
0
 public void onBackPressed() {
   if (inputMenu.onBackPressed()) {
     getActivity().finish();
     if (chatType == EaseConstant.CHATTYPE_GROUP) {
       EaseAtMessageHelper.get().removeAtMeGroup(toChatUsername);
       EaseAtMessageHelper.get().cleanToAtUserList();
     }
     if (chatType == EaseConstant.CHATTYPE_CHATROOM) {
       EMClient.getInstance().chatroomManager().leaveChatRoom(toChatUsername);
     }
   }
 }
Пример #2
0
 // send message
 protected void sendTextMessage(String content) {
   if (EaseAtMessageHelper.get().containsAtUsername(content)) {
     sendAtMessage(content);
   } else {
     EMMessage message = EMMessage.createTxtSendMessage(content, toChatUsername);
     sendMessage(message);
   }
 }
Пример #3
0
 /**
  * send @ message, only support group chat message
  *
  * @param content
  */
 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);
 }
Пример #4
0
 /**
  * input @
  *
  * @param username
  */
 protected void inputAtUsername(String username, boolean autoAddAtSymbol) {
   if (EMClient.getInstance().getCurrentUser().equals(username)
       || chatType != EaseConstant.CHATTYPE_GROUP) {
     return;
   }
   EaseAtMessageHelper.get().addAtUser(username);
   if (EaseUserUtils.getUserInfo(username) != null) {
     username = EaseUserUtils.getUserInfo(username).getNick();
   }
   if (autoAddAtSymbol) inputMenu.insertText("@" + username + " ");
   else inputMenu.insertText(username + " ");
 }
Пример #5
0
  @Override
  public void onResume() {
    super.onResume();
    if (isMessageListInited) messageList.refresh();
    EaseUI.getInstance().pushActivity(getActivity());
    // register the event listener when enter the foreground
    EMClient.getInstance().chatManager().addMessageListener(this);

    if (chatType == EaseConstant.CHATTYPE_GROUP) {
      EaseAtMessageHelper.get().removeAtMeGroup(toChatUsername);
    }
  }