+ Bitmap thumbnail;
+ iv.setTag(file.getFileId());
+
+ if (file.isImage()) {
+ String tagId = String.valueOf(file.getRemoteId());
+ thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(tagId);
+
+ if (thumbnail != null && !file.needsUpdateThumbnail()) {
+ iv.setImageBitmap(thumbnail);
+ } else {
+ // generate new Thumbnail
+ if (ThumbnailsCacheManager.cancelPotentialWork(file, iv)) {
+ final ThumbnailsCacheManager.ThumbnailGenerationTask task =
+ new ThumbnailsCacheManager.ThumbnailGenerationTask(
+ iv, mContainerActivity.getStorageManager(), mAccount
+ );
+ if (thumbnail == null) {
+ thumbnail = ThumbnailsCacheManager.mDefaultImg;
+ }
+ final ThumbnailsCacheManager.AsyncDrawable asyncDrawable =
+ new ThumbnailsCacheManager.AsyncDrawable(
+ MainApp.getAppContext().getResources(),
+ thumbnail,
+ task
+ );
+ iv.setImageDrawable(asyncDrawable);
+ task.execute(file);
+ }
+ }
+ } else {
+ // Name of the file, to deduce the icon to use in case the MIME type is not precise enough
+ String filename = file.getFileName();
+ iv.setImageResource(MimetypeIconUtil.getFileTypeIconId(mimetype, filename));
+ }