com.hyphenate.chat.EMVoiceMessageBody Java Examples

The following examples show how to use com.hyphenate.chat.EMVoiceMessageBody. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HxChatPresenter.java    From FamilyChat with Apache License 2.0 6 votes vote down vote up
/**
 * 重新发送某条消息
 */
public void resendMessage(EMMessage message, int position)
{
    EMConversation.EMConversationType conType = mViewImpl.getConversationType();
    String conId = mViewImpl.getConversationId();
    //移除已有消息
    HxChatHelper.getInstance().deleteMessage(conType, conId, message);
    mViewImpl.removeMessage(message, position);
    //重发消息
    switch (message.getType())
    {
        case TXT:
            EMTextMessageBody textMessageBody = (EMTextMessageBody) message.getBody();
            sendTextMessage(conType, conId, textMessageBody.getMessage());
            break;
        case VOICE:
            EMVoiceMessageBody voiceMessageBody = (EMVoiceMessageBody) message.getBody();
            sendVoiceMessage(conType, conId, voiceMessageBody.getLocalUrl(), voiceMessageBody.getLength());
            break;
        case IMAGE:
            EMImageMessageBody imageMessageBody = (EMImageMessageBody) message.getBody();
            sendImageMessage(conType, conId, imageMessageBody.getLocalUrl(), imageMessageBody.isSendOriginalImage());
            break;
    }
}
 
Example #2
Source File: EaseChatRowVoicePlayClickListener.java    From Social with Apache License 2.0 5 votes vote down vote up
public EaseChatRowVoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity context) {
	this.message = message;
	voiceBody = (EMVoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = context;
	this.chatType = message.getChatType();
}
 
Example #3
Source File: EaseChatRowVoicePlayClickListener.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public EaseChatRowVoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity context) {
	this.message = message;
	voiceBody = (EMVoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = context;
	this.chatType = message.getChatType();
}
 
Example #4
Source File: EaseChatRowVoicePlayClickListener.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
public EaseChatRowVoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity context) {
	this.message = message;
	voiceBody = (EMVoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = context;
	this.chatType = message.getChatType();
}
 
Example #5
Source File: VoiceMessageBaseItemView.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
VoiceClickListener(FrameAnimImageView imageView, EMMessage message, int position)
{
    this.mImageView = imageView;
    this.mMessage = message;
    this.mPosition = position;
    this.mBody = (EMVoiceMessageBody) mMessage.getBody();
}
 
Example #6
Source File: VoiceMessageBaseItemView.java    From FamilyChat with Apache License 2.0 4 votes vote down vote up
@Override
public void setMessageData(RcvHolder holder, final EMMessage emMessage, final int position)
{
    final EMVoiceMessageBody messageBody = (EMVoiceMessageBody) emMessage.getBody();
    final FrameAnimImageView imgLabel = holder.findView(R.id.img_chat_listitem_voice_content);
    TextView tvLength = holder.findView(R.id.tv_chat_listitem_voice_content);
    View vLayout = holder.findView(R.id.fl_chat_listitem_voice_content);

    int voiceLength = messageBody.getLength();
    ViewGroup.LayoutParams layoutParams = vLayout.getLayoutParams();
    if (voiceLength <= MIN_VOICE_LENGTH)
        layoutParams.width = MIN_LAYOUT_WIDTH;
    else if (voiceLength >= MAX_VOICE_LENGTH)
        layoutParams.width = MAX_LAYOUT_WIDTH;
    else
        layoutParams.width = MIN_LAYOUT_WIDTH
                + (MAX_LAYOUT_WIDTH - MIN_LAYOUT_WIDTH)
                * (voiceLength - MIN_VOICE_LENGTH) / 5;//5=MAX_VOICE_LENGTH-MIN_VOICE_LENGTH
    vLayout.setLayoutParams(layoutParams);

    if (mPresenter.getCurPlayVoicePosition() == position)
    {
        if (emMessage.direct() == EMMessage.Direct.SEND)
            imgLabel.start(mAnimRight, true, ANIM_DURATION);
        else
            imgLabel.start(mAnimLeft, true, ANIM_DURATION);
    } else
    {
        imgLabel.stop();
        if (emMessage.direct() == EMMessage.Direct.SEND)
            imgLabel.setImageResource(R.drawable.ic_voice_right03);
        else
            imgLabel.setImageResource(R.drawable.ic_voice_left03);
    }

    //设置时长
    String lengthEx = mContext.getResources().getString(R.string.tv_chat_listitem_voice_length_Ex);
    String length = lengthEx.replaceFirst("%%1", String.valueOf(voiceLength));
    tvLength.setText(length);

    //是否已听
    if (emMessage.direct() == EMMessage.Direct.RECEIVE)
    {
        TextView tvUnlisten = holder.findView(R.id.tv_chat_listitem_voice_unlisten);
        if (emMessage.isListened())
            tvUnlisten.setVisibility(View.GONE);
        else
            tvUnlisten.setVisibility(View.VISIBLE);
    }

    //设置点击事件
    holder.setClickListener(R.id.fl_chat_listitem_voice_content, new VoiceClickListener(imgLabel, emMessage, position));

    setMessage(holder, emMessage, position);
}