【发布时间】:2016-09-14 13:29:02
【问题描述】:
我正在开发一个文件管理器,当我检测到当前目录中的图像时,我想向用户显示一个缩略图。我可以做到这一点,唯一的问题是当目录中有图像时,所有 UI 都会变得缓慢和滞后。我想问一些提高性能的方法。以下是代码片段:
这里我检查文件是否为图像:
fileName = file.getName();
fileName = fileName.substring(fileName.lastIndexOf('.') + 1);
if(fileName.equals("jpg"))
dir.add(new Item(ff.getName(), ff.length() + " Byte", date_modify, ff.getAbsolutePath(), "image_icon"));
这里是FileAdapter代码来设置recycler view行的imageView:
if(item.getImage().equals("image_icon")){
Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(item.getPath()),
100, 100);
holder.icon.setImageBitmap(ThumbImage);
}
如果需要更多代码,请告诉我。
【问题讨论】:
-
使用Glide加载图片
标签: android image performance android-bitmap