Beispiel #1
0
  /**
   * 牙牙表情等gif类型的消息: 1. 设定内容Emoparser 2. 点击事件 单击跳转、 双击方法、长按pop menu 点击头像的事件 跳转
   *
   * @param position
   * @param convertView
   * @param viewGroup
   * @param isMine
   * @return
   */
  private View gifMsgRender(
      final int position, View convertView, final ViewGroup viewGroup, final boolean isMine) {
    EmojiRenderView gifRenderView;
    final TextMessage textMessage = (TextMessage) msgObjectList.get(position);
    UserEntity userEntity = imService.getContactManager().findContact(textMessage.getFromId());
    if (null == convertView) {
      gifRenderView =
          EmojiRenderView.inflater(
              ctx, viewGroup, isMine); // new TextRenderView(ctx,viewGroup,isMine);
    } else {
      gifRenderView = (EmojiRenderView) convertView;
    }

    final ImageView imageView = gifRenderView.getMessageContent();
    // 失败事件添加
    gifRenderView
        .getMessageFailed()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                MessageOperatePopup popup =
                    getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
                popup.show(imageView, DBConstant.SHOW_GIF_TYPE, true, isMine);
              }
            });

    imageView.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            MessageOperatePopup popup =
                getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
            boolean bResend = textMessage.getStatus() == MessageConstant.MSG_FAILURE;
            popup.show(imageView, DBConstant.SHOW_GIF_TYPE, bResend, isMine);

            return true;
          }
        });

    imageView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            final String content = textMessage.getContent();
            Intent intent = new Intent(ctx, PreviewGifActivity.class);
            intent.putExtra(IntentConstant.PREVIEW_TEXT_CONTENT, content);
            ctx.startActivity(intent);
            ((Activity) ctx).overridePendingTransition(R.anim.tt_image_enter, R.anim.tt_stay);
          }
        });

    gifRenderView.render(textMessage, userEntity, ctx);
    return gifRenderView;
  }
Beispiel #2
0
  /**
   * text类型的: 1. 设定内容Emoparser 2. 点击事件 单击跳转、 双击方法、长按pop menu 点击头像的事件 跳转
   *
   * @param position
   * @param convertView
   * @param viewGroup
   * @param isMine
   * @return
   */
  private View textMsgRender(
      final int position, View convertView, final ViewGroup viewGroup, final boolean isMine) {
    TextRenderView textRenderView;
    final TextMessage textMessage = (TextMessage) msgObjectList.get(position);
    UserEntity userEntity = imService.getContactManager().findContact(textMessage.getFromId());

    if (null == convertView) {
      textRenderView =
          TextRenderView.inflater(
              ctx, viewGroup, isMine); // new TextRenderView(ctx,viewGroup,isMine);
    } else {
      textRenderView = (TextRenderView) convertView;
    }

    final TextView textView = textRenderView.getMessageContent();

    // 失败事件添加
    textRenderView
        .getMessageFailed()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                MessageOperatePopup popup =
                    getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
                popup.show(textView, DBConstant.SHOW_ORIGIN_TEXT_TYPE, true, isMine);
              }
            });

    textView.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            // 弹窗类型
            MessageOperatePopup popup =
                getPopMenu(viewGroup, new OperateItemClickListener(textMessage, position));
            boolean bResend = textMessage.getStatus() == MessageConstant.MSG_FAILURE;
            popup.show(textView, DBConstant.SHOW_ORIGIN_TEXT_TYPE, bResend, isMine);
            return true;
          }
        });

    // url 路径可以设定 跳转哦哦
    final String content = textMessage.getContent();
    textView.setOnTouchListener(
        new OnDoubleClickListener() {
          @Override
          public void onClick(View view) {
            // todo
          }

          @Override
          public void onDoubleClick(View view) {
            Intent intent = new Intent(ctx, PreviewTextActivity.class);
            intent.putExtra(IntentConstant.PREVIEW_TEXT_CONTENT, content);
            ctx.startActivity(intent);
          }
        });
    textRenderView.render(textMessage, userEntity, ctx);
    return textRenderView;
  }