环信发送图片报错

在尝试发送图片时遇到问题,原始代码存在错误。通过更新`EaseChatRowImage`类来修复,确保缩略图加载成功后重用drawable,从而避免发送图片失败。
摘要由CSDN通过智能技术生成

原文 发送图片失败
package com.hyphenate.easeui.widget.chatrow;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.support.v4.os.AsyncTaskCompat;
import android.view.View;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMFileMessageBody;
import com.hyphenate.chat.EMImageMessageBody;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.R;
import com.hyphenate.easeui.model.EaseImageCache;
import com.hyphenate.easeui.utils.EaseImageUtils;
import java.io.File;

public class EaseChatRowImage extends EaseChatRowFile{

protected ImageView imageView;
private EMImageMessageBody imgBody;

public EaseChatRowImage(Context context, EMMessage message, int position, BaseAdapter adapter) {
    super(context, message, position, adapter);
}

@Override
protected void onInflateView() {
    inflater.inflate(message.direct() == EMMessage.Direct.RECEIVE ? R.layout.ease_row_received_picture : R.layout.ease_row_sent_picture, this);
}

@Override
protected void onFindViewById() {
    percentageView = (TextView) findViewById(R.id.percentage);
    imageView = (ImageView) findViewById(R.id.image);
}


@Override
protected void onSetUpView() {
    imgBody = (EMImageMessageBody) message.getBody();

    // received messages
    if (message.direct() == EMMessage.Direct.RECEIVE) {
        return;
    }

    String filePath = imgBody.getLocalUrl();
    String thumbPath = EaseImageUtils.getThumbnailImagePath(imgBody.getLocalUrl());
    showImageView(thumbPath, filePath, message);
}

@Override
protected void onViewUpdate(EMMessage msg) {
    if (msg.direct() == EMMessage.Direct.SEND) {
        if(EMClient.getInstance().getOptions().getAutodownloadThumbnail()){
            super.onViewUpdate(msg);
        }else{
            if (imgBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.DOWNLOADING ||
                    imgBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.PENDING ||
                        imgBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.FAILED) {
                progressBar.setVisibility(View.INVISIBLE);
                percentageView.setVisibility(View.INVISIBLE);
                imageView.setImageResource(R.drawable.ease_default_image);
            } else {
                progressBar.setVisibility(View.GONE);
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值