|
@@ -485,9 +485,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
&& fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId() != null &&
|
|
&& fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId() != null &&
|
|
item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) {
|
|
item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) {
|
|
// Thumbnail in Cache?
|
|
// Thumbnail in Cache?
|
|
- Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
|
|
|
- String.valueOf(fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId())
|
|
|
|
- );
|
|
|
|
|
|
+ Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(String.valueOf(fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId()));
|
|
|
|
+
|
|
if (thumbnail != null && !fakeFileToCheatThumbnailsCacheManagerInterface.isUpdateThumbnailNeeded()) {
|
|
if (thumbnail != null && !fakeFileToCheatThumbnailsCacheManagerInterface.isUpdateThumbnailNeeded()) {
|
|
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
|
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
|
} else {
|
|
} else {
|
|
@@ -520,47 +519,51 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
}
|
|
}
|
|
|
|
|
|
if ("image/png".equals(item.getMimeType())) {
|
|
if ("image/png".equals(item.getMimeType())) {
|
|
- itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources()
|
|
|
|
- .getColor(R.color.bg_default));
|
|
|
|
|
|
+ itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources().getColor(R.color.bg_default));
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
} else if (MimeTypeUtil.isImage(fakeFileToCheatThumbnailsCacheManagerInterface)) {
|
|
} else if (MimeTypeUtil.isImage(fakeFileToCheatThumbnailsCacheManagerInterface)) {
|
|
File file = new File(item.getLocalPath());
|
|
File file = new File(item.getLocalPath());
|
|
- // Thumbnail in Cache?
|
|
|
|
- Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
|
|
|
- String.valueOf(file.hashCode()));
|
|
|
|
|
|
+ Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(String.valueOf(file.hashCode()));
|
|
|
|
+
|
|
if (thumbnail != null) {
|
|
if (thumbnail != null) {
|
|
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
|
itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail);
|
|
- } else {
|
|
|
|
- // generate new Thumbnail
|
|
|
|
- if (allowedToCreateNewThumbnail) {
|
|
|
|
- final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
|
|
|
- new ThumbnailsCacheManager.ThumbnailGenerationTask(itemViewHolder.binding.thumbnail);
|
|
|
|
|
|
+ } else if (allowedToCreateNewThumbnail) {
|
|
|
|
+ getThumbnailFromFileTypeAndSetIcon(item.getLocalPath(), itemViewHolder);
|
|
|
|
+
|
|
|
|
+ final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
|
|
|
+ new ThumbnailsCacheManager.ThumbnailGenerationTask(itemViewHolder.binding.thumbnail);
|
|
|
|
+
|
|
|
|
+ if (MimeTypeUtil.isVideo(file)) {
|
|
|
|
+ thumbnail = ThumbnailsCacheManager.mDefaultVideo;
|
|
|
|
+ } else {
|
|
|
|
+ thumbnail = ThumbnailsCacheManager.mDefaultImg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
|
|
|
+ new ThumbnailsCacheManager.AsyncThumbnailDrawable(parentActivity.getResources(), thumbnail,
|
|
|
|
+ task);
|
|
|
|
|
|
- if (MimeTypeUtil.isVideo(file)) {
|
|
|
|
- thumbnail = ThumbnailsCacheManager.mDefaultVideo;
|
|
|
|
- } else {
|
|
|
|
- thumbnail = ThumbnailsCacheManager.mDefaultImg;
|
|
|
|
|
|
+ task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file, null));
|
|
|
|
+ task.setListener(new ThumbnailsCacheManager.ThumbnailGenerationTask.Listener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess() {
|
|
|
|
+ itemViewHolder.binding.thumbnail.setImageDrawable(asyncDrawable);
|
|
}
|
|
}
|
|
|
|
|
|
- final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
|
|
|
- new ThumbnailsCacheManager.AsyncThumbnailDrawable(parentActivity.getResources(), thumbnail,
|
|
|
|
- task);
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void onError() {
|
|
|
|
+ getThumbnailFromFileTypeAndSetIcon(item.getLocalPath(), itemViewHolder);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
- itemViewHolder.binding.thumbnail.setImageDrawable(asyncDrawable);
|
|
|
|
- task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file, null));
|
|
|
|
- Log_OC.v(TAG, "Executing task to generate a new thumbnail");
|
|
|
|
- }
|
|
|
|
|
|
+ Log_OC.v(TAG, "Executing task to generate a new thumbnail");
|
|
}
|
|
}
|
|
|
|
|
|
if ("image/png".equalsIgnoreCase(item.getMimeType())) {
|
|
if ("image/png".equalsIgnoreCase(item.getMimeType())) {
|
|
- itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources()
|
|
|
|
- .getColor(R.color.bg_default));
|
|
|
|
|
|
+ itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources().getColor(R.color.bg_default));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (optionalUser.isPresent()) {
|
|
if (optionalUser.isPresent()) {
|
|
- final User user = optionalUser.get();
|
|
|
|
final Drawable icon = MimeTypeUtil.getFileTypeIcon(item.getMimeType(),
|
|
final Drawable icon = MimeTypeUtil.getFileTypeIcon(item.getMimeType(),
|
|
fileName,
|
|
fileName,
|
|
parentActivity,
|
|
parentActivity,
|
|
@@ -570,6 +573,12 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void getThumbnailFromFileTypeAndSetIcon(String localPath, ItemViewHolder itemViewHolder) {
|
|
|
|
+ Drawable drawable = MimeTypeUtil.getIcon(localPath, parentActivity, viewThemeUtils);
|
|
|
|
+ if (drawable == null) return;
|
|
|
|
+ itemViewHolder.binding.thumbnail.setImageDrawable(drawable);
|
|
|
|
+ }
|
|
|
|
+
|
|
private boolean checkAndOpenConflictResolutionDialog(User user,
|
|
private boolean checkAndOpenConflictResolutionDialog(User user,
|
|
ItemViewHolder itemViewHolder,
|
|
ItemViewHolder itemViewHolder,
|
|
OCUpload item,
|
|
OCUpload item,
|