AsyncTaskCompat找不到,环信easeui集成的一些坑

环信的文档写的很简单但是导入easeui后项目中就出问题了java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/AsyncTaskCompat;

试了网上的解决方案:

EaseChatRowImage 在这个类替换为

new AsyncTask<Object, Void, Bitmap>() {

@Override
protected Bitmap doInBackground(Object... args) {
File file = new File(thumbernailPath);
if (file.exists()) {
return EaseImageUtils.decodeScaleImage(thumbernailPath, 160, 160);
} else if (new File(imgBody.thumbnailLocalPath()).exists()) {
return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
}
else {
if (message.direct() == EMMessage.Direct.SEND) {
if (localFullSizePath != null && new File(localFullSizePath).exists()) {
return EaseImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
} else {
return null;
}
} else {
return null;
}
}
}

protected void onPostExecute(Bitmap image) {
if (image != null) {
imageView.setImageBitmap(image);
EaseImageCache.getInstance().put(thumbernailPath, image);
} else {
if (message.status() == EMMessage.Status.FAIL) {
if (isNetWorkConnected(activity)) {
new Thread(new Runnable() {

@Override
public void run() {
EMClient.getInstance().chatManager().downloadThumbnail(message);
}
}).start();
}
}

}
}

}.execute();


但是 我试了 还是么有用啊

经过尝试重新这个方法,终于解决了

附上源代码,完美解决。

/**
     * load image into image view
     */
    private void showImageView(final String thumbernailPath, final String localFullSizePath, final EMMessage message) {
        // first check if the thumbnail image already loaded into cache s
        Bitmap bitmap = EaseImageCache.getInstance().get(thumbernailPath);

        if (bitmap != null) {
            // thumbnail image is already loaded, reuse the drawable
            imageView.setImageBitmap(bitmap);
        } else {
            imageView.setImageResource(R.drawable.ease_default_image);
            DownLoadImageTask downLoadImageTask=new DownLoadImageTask();
            downLoadImageTask.execute(new String[]{thumbernailPath,localFullSizePath});
//            AsyncTaskCompat.executeParallel(new AsyncTask<Object, Void, Bitmap>() {
//
//            @Override
//            protected Bitmap doInBackground(Object... args) {
//                File file = new File(thumbernailPath);
//                if (file.exists()) {
//                    return EaseImageUtils.decodeScaleImage(thumbernailPath, 160, 160);
//                } else if (new File(imgBody.thumbnailLocalPath()).exists()) {
//                    return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
//                } else {
//                    if (message.direct() == EMMessage.Direct.SEND) {
//                        if (localFullSizePath != null && new File(localFullSizePath).exists()) {
//                            return EaseImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
//                        } else {
//                            return null;
//                        }
//                    } else {
//                        return null;
//                    }
//                }
//            }
//
//            protected void onPostExecute(Bitmap image) {
//                if (image != null) {
//                    imageView.setImageBitmap(image);
//                    EaseImageCache.getInstance().put(thumbernailPath, image);
//                }
//            }
//        });
    }
    }

    class DownLoadImageTask extends AsyncTask<String, Void, Bitmap> {
        String s= "";

        @Override
        protected Bitmap doInBackground(String... params) {
            s=params[0];
            File file = new File(params[0]);
            if (file.exists()) {
                return EaseImageUtils.decodeScaleImage(params[0], 160, 160);
            } else if (new File(imgBody.thumbnailLocalPath()).exists()) {
                return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
            } else {
                if (message.direct() == EMMessage.Direct.SEND) {
                    if (params[1] != null && new File(params[1]).exists()) {
                        return EaseImageUtils.decodeScaleImage(params[2], 160, 160);
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            }
        }

        protected void onPostExecute(Bitmap image) {
            if (image != null) {
                imageView.setImageBitmap(image);
                EaseImageCache.getInstance().put(s, image);
            }
        }

    }

                
  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值