Beispiel #1
0
  /**
   * 语音的路径,判断收发的状态 展现的状态 播放动画相关 获取语音的读取状态/ 语音长按事件
   *
   * @param position
   * @param convertView
   * @param parent
   * @param isMine
   * @return
   */
  private View audioMsgRender(
      final int position, View convertView, final ViewGroup parent, final boolean isMine) {
    AudioRenderView audioRenderView;
    final AudioMessage audioMessage = (AudioMessage) msgObjectList.get(position);
    UserEntity entity = imService.getContactManager().findContact(audioMessage.getFromId());
    if (null == convertView) {
      audioRenderView = AudioRenderView.inflater(ctx, parent, isMine);
    } else {
      audioRenderView = (AudioRenderView) convertView;
    }
    final String audioPath = audioMessage.getAudioPath();

    final View messageLayout = audioRenderView.getMessageLayout();
    if (!TextUtils.isEmpty(audioPath)) {
      // 播放的路径为空,这个消息应该如何展示
      messageLayout.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              MessageOperatePopup popup =
                  getPopMenu(parent, new OperateItemClickListener(audioMessage, position));
              boolean bResend = audioMessage.getStatus() == MessageConstant.MSG_FAILURE;
              popup.show(messageLayout, DBConstant.SHOW_AUDIO_TYPE, bResend, isMine);
              return true;
            }
          });
    }

    audioRenderView
        .getMessageFailed()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View arg0) {
                MessageOperatePopup popup =
                    getPopMenu(parent, new OperateItemClickListener(audioMessage, position));
                popup.show(messageLayout, DBConstant.SHOW_AUDIO_TYPE, true, isMine);
              }
            });

    audioRenderView.setBtnImageListener(
        new AudioRenderView.BtnImageListener() {
          @Override
          public void onClickUnread() {
            logger.d("chat#audio#set audio meessage read status");
            audioMessage.setReadStatus(MessageConstant.AUDIO_READED);
            imService.getDbInterface().insertOrUpdateMessage(audioMessage);
          }

          @Override
          public void onClickReaded() {}
        });
    audioRenderView.render(audioMessage, entity, ctx);
    return audioRenderView;
  }
Beispiel #2
0
 /** @param audioLen @Description 录音结束后处理录音数据 */
 private void onRecordVoiceEnd(float audioLen) {
   logger.d("message_activity#chat#audio#onRecordVoiceEnd audioLen:%f", audioLen);
   AudioMessage audioMessage =
       AudioMessage.buildForSend(audioLen, audioSavePath, loginUser, peerEntity);
   imService.getMessageManager().sendVoice(audioMessage);
   pushList(audioMessage);
 }