android 第一次进入聊天界面,图片加载

蒲锦_up 蒲锦_up 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
/**
* 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);
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);
}
}
});
}
}


现在遇到个问题,就是在刷新加载(比如第一进入聊天页面或者下拉刷新)的时候,加载图片消息,会因为图片大小不规则,造成显示图片item的时候因为图片组件的重新绘制计算宽高而上下跳动。

环信是用listview+baseadapter,这个问题也没有。应该是根据图片的尺寸动态计算显示大小,但是我在环信的代码没看见这方面的代码。


我使用的是recyclerview,现在就是遇到这个问题,导致了后面几个问题。
1.下拉刷新定位到某个posoiton的时候,不准确。
2. 第一次进入聊天界面,显示图片不能滑动到底部,图片会上下跳动
3.scrolltopostion()方法也不灵了,不能定位位置上。

哪位知道的大神知道的,指点下嘛,谢谢!

...全文
评论 3
收藏 已收藏
分享
返回顶部
蒲锦_up
Android 80,489 成员 91,375 内容