Exemplo n.º 1
0
 /** 设定聊天名称 1. 如果是user类型, 点击触发UserProfile 2. 如果是群组,检测自己是不是还在群中 */
 private void setTitleByUser() {
   setTitle(peerEntity.getMainName());
   int peerType = peerEntity.getType();
   switch (peerType) {
     case DBConstant.SESSION_TYPE_GROUP:
       {
         GroupEntity group = (GroupEntity) peerEntity;
         Set<Integer> memberLists = group.getlistGroupMemberIds();
         if (!memberLists.contains(loginUser.getPeerId())) {
           Toast.makeText(MessageActivity.this, R.string.no_group_member, Toast.LENGTH_SHORT)
               .show();
         }
       }
       break;
     case DBConstant.SESSION_TYPE_SINGLE:
       {
         topTitleTxt.setOnClickListener(
             new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                 IMUIHelper.openUserProfileActivity(MessageActivity.this, peerEntity.getPeerId());
               }
             });
       }
       break;
   }
 }
Exemplo n.º 2
0
  // 在视图中,长按用户信息条目弹出的对话框
  public static void handleContactItemLongClick(final UserEntity contact, final Context ctx) {
    if (contact == null || ctx == null) {
      return;
    }
    AlertDialog.Builder builder =
        new AlertDialog.Builder(
            new ContextThemeWrapper(ctx, android.R.style.Theme_Holo_Light_Dialog));
    builder.setTitle(contact.getMainName());
    String[] items =
        new String[] {ctx.getString(R.string.check_profile), ctx.getString(R.string.start_session)};

    final int userId = contact.getPeerId();
    builder.setItems(
        items,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case 0:
                IMUIHelper.openUserProfileActivity(ctx, userId);
                break;
              case 1:
                IMUIHelper.openChatActivity(ctx, contact.getSessionKey());
                break;
            }
          }
        });
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(true);
    alertDialog.show();
  }
Exemplo n.º 3
0
  @Override
  public int getItemViewType(int position) {
    try {
      /** 默认是失败类型 */
      RenderType type = RenderType.MESSAGE_TYPE_INVALID;

      Object obj = msgObjectList.get(position);
      if (obj instanceof Integer) {
        type = RenderType.MESSAGE_TYPE_TIME_TITLE;
      } else if (obj instanceof MessageEntity) {
        MessageEntity info = (MessageEntity) obj;
        boolean isMine = info.getFromId() == loginUser.getPeerId();
        switch (info.getDisplayType()) {
          case DBConstant.SHOW_AUDIO_TYPE:
            type =
                isMine ? RenderType.MESSAGE_TYPE_MINE_AUDIO : RenderType.MESSAGE_TYPE_OTHER_AUDIO;
            break;
          case DBConstant.SHOW_IMAGE_TYPE:
            ImageMessage imageMessage = (ImageMessage) info;
            if (CommonUtil.gifCheck(imageMessage.getUrl())) {
              type =
                  isMine
                      ? RenderType.MESSAGE_TYPE_MINE_GIF_IMAGE
                      : RenderType.MESSAGE_TYPE_OTHER_GIF_IMAGE;
            } else {
              type =
                  isMine ? RenderType.MESSAGE_TYPE_MINE_IMAGE : RenderType.MESSAGE_TYPE_OTHER_IMAGE;
            }

            break;
          case DBConstant.SHOW_ORIGIN_TEXT_TYPE:
            if (info.isGIfEmo()) {
              type = isMine ? RenderType.MESSAGE_TYPE_MINE_GIF : RenderType.MESSAGE_TYPE_OTHER_GIF;
            } else {
              type =
                  isMine ? RenderType.MESSAGE_TYPE_MINE_TETX : RenderType.MESSAGE_TYPE_OTHER_TEXT;
            }

            break;
          case DBConstant.SHOW_MIX_TEXT:
            //
            logger.e("混合的消息类型%s", obj);
          default:
            break;
        }
      }
      return type.ordinal();
    } catch (Exception e) {
      logger.e(e.getMessage());
      return RenderType.MESSAGE_TYPE_INVALID.ordinal();
    }
  }