Exemple #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;
  }
Exemple #2
0
        @Override
        public void onItemClick(int facesPos, int viewIndex) {
          int resId = Emoparser.getInstance(MessageActivity.this).getYayaResIdList()[facesPos];
          logger.d("message_activity#yayaEmoGridView be clicked");

          String content =
              Emoparser.getInstance(MessageActivity.this).getYayaIdPhraseMap().get(resId);
          if (content.equals("")) {
            Toast.makeText(
                    MessageActivity.this,
                    getResources().getString(R.string.message_null),
                    Toast.LENGTH_LONG)
                .show();
            return;
          }

          TextMessage textMessage = TextMessage.buildForSend(content, loginUser, peerEntity);
          imService.getMessageManager().sendText(textMessage);
          pushList(textMessage);
          scrollToBottomListItem();
        }
Exemple #3
0
  @Override
  public void onClick(View v) {
    final int id = v.getId();
    switch (id) {
      case R.id.left_btn:
      case R.id.left_txt:
        actFinish();
        break;
      case R.id.right_btn:
        showGroupManageActivity();
        break;
      case R.id.show_add_photo_btn:
        {
          recordAudioBtn.setVisibility(View.GONE);
          keyboardInputImg.setVisibility(View.GONE);
          messageEdt.setVisibility(View.VISIBLE);
          audioInputImg.setVisibility(View.VISIBLE);
          addEmoBtn.setVisibility(View.VISIBLE);

          if (keyboardHeight != 0) {
            this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
          }
          if (addOthersPanelView.getVisibility() == View.VISIBLE) {
            if (!messageEdt.hasFocus()) {
              messageEdt.requestFocus();
            }
            inputManager.toggleSoftInputFromWindow(messageEdt.getWindowToken(), 1, 0);
            if (keyboardHeight == 0) {
              addOthersPanelView.setVisibility(View.GONE);
            }
          } else if (addOthersPanelView.getVisibility() == View.GONE) {
            addOthersPanelView.setVisibility(View.VISIBLE);
            inputManager.hideSoftInputFromWindow(messageEdt.getWindowToken(), 0);
          }
          if (null != emoLayout && emoLayout.getVisibility() == View.VISIBLE) {
            emoLayout.setVisibility(View.GONE);
          }

          scrollToBottomListItem();
        }
        break;
      case R.id.take_photo_btn:
        {
          if (albumList.size() < 1) {
            Toast.makeText(
                    MessageActivity.this,
                    getResources().getString(R.string.not_found_album),
                    Toast.LENGTH_LONG)
                .show();
            return;
          }
          // 选择图片的时候要将session的整个回话 传过来
          Intent intent = new Intent(MessageActivity.this, PickPhotoActivity.class);
          intent.putExtra(IntentConstant.KEY_SESSION_KEY, currentSessionKey);
          startActivityForResult(intent, SysConstant.ALBUM_BACK_DATA);

          MessageActivity.this.overridePendingTransition(R.anim.tt_album_enter, R.anim.tt_stay);
          // addOthersPanelView.setVisibility(View.GONE);
          messageEdt.clearFocus(); // 切记清除焦点
          scrollToBottomListItem();
        }
        break;
        //            case R.id.take_camera_btn: {
        //                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        //                takePhotoSavePath = CommonUtil.getImageSavePath(String.valueOf(System
        //                        .currentTimeMillis())
        //                        + ".jpg");
        //                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new
        // File(takePhotoSavePath)));
        //                startActivityForResult(intent, SysConstant.CAMERA_WITH_DATA);
        //                //addOthersPanelView.setVisibility(View.GONE);
        //                messageEdt.clearFocus();//切记清除焦点
        //                scrollToBottomListItem();
        //            }
        //            break;
      case R.id.take_camera_btn:
        {
          Intent intent = new Intent(MessageActivity.this, CameraActivity.class);
          intent.putExtra(IntentConstant.KEY_SESSION_KEY, currentSessionKey);
          startActivity(intent);
        }
        break;
      case R.id.show_emo_btn:
        {
          /** yingmu 调整成键盘输出 */
          recordAudioBtn.setVisibility(View.GONE);
          keyboardInputImg.setVisibility(View.GONE);
          messageEdt.setVisibility(View.VISIBLE);
          audioInputImg.setVisibility(View.VISIBLE);
          addEmoBtn.setVisibility(View.VISIBLE);
          /** end */
          if (keyboardHeight != 0) {
            this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
          }
          if (emoLayout.getVisibility() == View.VISIBLE) {
            if (!messageEdt.hasFocus()) {
              messageEdt.requestFocus();
            }
            inputManager.toggleSoftInputFromWindow(messageEdt.getWindowToken(), 1, 0);
            if (keyboardHeight == 0) {
              emoLayout.setVisibility(View.GONE);
            }
          } else if (emoLayout.getVisibility() == View.GONE) {
            emoLayout.setVisibility(View.VISIBLE);
            yayaEmoGridView.setVisibility(View.VISIBLE);
            emoRadioGroup.check(R.id.tab1);
            emoGridView.setVisibility(View.GONE);
            inputManager.hideSoftInputFromWindow(messageEdt.getWindowToken(), 0);
          }
          if (addOthersPanelView.getVisibility() == View.VISIBLE) {
            addOthersPanelView.setVisibility(View.GONE);
          }
        }
        break;
      case R.id.send_message_btn:
        {
          logger.d("message_activity#send btn clicked");

          String content = messageEdt.getText().toString();
          logger.d("message_activity#chat content:%s", content);
          if (content.trim().equals("")) {
            Toast.makeText(
                    MessageActivity.this,
                    getResources().getString(R.string.message_null),
                    Toast.LENGTH_LONG)
                .show();
            return;
          }
          TextMessage textMessage = TextMessage.buildForSend(content, loginUser, peerEntity);
          imService.getMessageManager().sendText(textMessage);
          messageEdt.setText("");
          pushList(textMessage);
          scrollToBottomListItem();
        }
        break;
      case R.id.voice_btn:
        {
          inputManager.hideSoftInputFromWindow(messageEdt.getWindowToken(), 0);
          messageEdt.setVisibility(View.GONE);
          audioInputImg.setVisibility(View.GONE);
          recordAudioBtn.setVisibility(View.VISIBLE);
          keyboardInputImg.setVisibility(View.VISIBLE);
          emoLayout.setVisibility(View.GONE);
          addOthersPanelView.setVisibility(View.GONE);
          messageEdt.setText("");
        }
        break;
      case R.id.show_keyboard_btn:
        {
          recordAudioBtn.setVisibility(View.GONE);
          keyboardInputImg.setVisibility(View.GONE);
          messageEdt.setVisibility(View.VISIBLE);
          audioInputImg.setVisibility(View.VISIBLE);
          addEmoBtn.setVisibility(View.VISIBLE);
        }
        break;
      case R.id.message_text:
        break;
      case R.id.tt_new_msg_tip:
        {
          scrollToBottomListItem();
          textView_new_msg_tip.setVisibility(View.GONE);
        }
        break;
    }
  }
Exemple #4
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;
  }