|
17 | 17 | import android.content.ContentValues;
|
18 | 18 | import android.content.res.ColorStateList;
|
19 | 19 | import android.content.res.Resources;
|
20 |
| -import android.graphics.Bitmap; |
21 | 20 | import android.graphics.Color;
|
22 | 21 | import android.graphics.drawable.Drawable;
|
23 | 22 | import android.os.Handler;
|
|
74 | 73 | import com.owncloud.android.ui.fragment.SearchType;
|
75 | 74 | import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
76 | 75 | import com.owncloud.android.ui.preview.PreviewTextFragment;
|
77 |
| -import com.owncloud.android.utils.BitmapUtils; |
78 | 76 | import com.owncloud.android.utils.DisplayUtils;
|
79 | 77 | import com.owncloud.android.utils.FileSortOrder;
|
80 | 78 | import com.owncloud.android.utils.FileStorageUtils;
|
|
91 | 89 | import java.util.Locale;
|
92 | 90 | import java.util.Set;
|
93 | 91 | import java.util.UUID;
|
94 |
| -import java.util.concurrent.ExecutorService; |
95 |
| -import java.util.concurrent.Executors; |
| 92 | +import java.util.stream.Collectors; |
96 | 93 |
|
97 | 94 | import androidx.annotation.NonNull;
|
98 | 95 | import androidx.annotation.Nullable;
|
@@ -524,8 +521,6 @@ private void bindListGridItemViewHolder(ListGridItemViewHolder holder, OCFile fi
|
524 | 521 | holder.getFileName().setVisibility(View.VISIBLE);
|
525 | 522 | }
|
526 | 523 | }
|
527 |
| - |
528 |
| - configureThumbnail(holder, file); |
529 | 524 | }
|
530 | 525 |
|
531 | 526 | private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
|
@@ -633,8 +628,6 @@ private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
|
633 | 628 | } else {
|
634 | 629 | holder.getOverflowMenu().setImageResource(R.drawable.ic_dots_vertical);
|
635 | 630 | }
|
636 |
| - |
637 |
| - configureThumbnail(holder, file); |
638 | 631 | }
|
639 | 632 |
|
640 | 633 | private void applyChipVisuals(Chip chip, Tag tag) {
|
@@ -674,44 +667,6 @@ private String getFileSizeText(OCFile file, long size) {
|
674 | 667 | return activity.getString(R.string.oc_file_list_adapter_offline_operation_description_text);
|
675 | 668 | }
|
676 | 669 |
|
677 |
| - private final ExecutorService executorService = Executors.newCachedThreadPool(); |
678 |
| - |
679 |
| - private void configureThumbnail(ListViewHolder holder, OCFile file) { |
680 |
| - final var context = MainApp.getAppContext(); |
681 |
| - |
682 |
| - if (file.isOfflineOperation()) { |
683 |
| - if (file.isFolder()) { |
684 |
| - Drawable icon = ContextCompat.getDrawable(context, R.drawable.ic_folder_offline); |
685 |
| - holder.getThumbnail().setImageDrawable(icon); |
686 |
| - } else { |
687 |
| - executorService.execute(() -> { |
688 |
| - OfflineOperationEntity entity = mStorageManager.offlineOperationDao.getByPath(file.getDecryptedRemotePath()); |
689 |
| - |
690 |
| - if (entity != null && entity.getType() != null && entity.getType() instanceof OfflineOperationType.CreateFile createFileOperation) { |
691 |
| - Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(createFileOperation.getLocalPath(), holder.getThumbnail().getWidth(), holder.getThumbnail().getHeight()); |
692 |
| - if (bitmap == null) return; |
693 |
| - |
694 |
| - Bitmap thumbnail = BitmapUtils.addColorFilter(bitmap, Color.GRAY,100); |
695 |
| - activity.runOnUiThread(() -> holder.getThumbnail().setImageBitmap(thumbnail)); |
696 |
| - } |
697 |
| - }); |
698 |
| - } |
699 |
| - } else { |
700 |
| - boolean isAutoUpload = SyncedFolderProvider.isAutoUploadFolder(syncedFolderProvider, file, user); |
701 |
| - boolean isDarkModeActive = preferences.isDarkModeEnabled(); |
702 |
| - Drawable icon = MimeTypeUtil.getOCFileIcon(file, context, viewThemeUtils, isAutoUpload, isDarkModeActive); |
703 |
| - holder.getThumbnail().setImageDrawable(icon); |
704 |
| - |
705 |
| - if (!file.isFolder()) { |
706 |
| - ViewExtensionsKt.makeRounded(holder.getThumbnail(), context, 4); |
707 |
| - } |
708 |
| - } |
709 |
| - } |
710 |
| - |
711 |
| - public void onDestroy() { |
712 |
| - executorService.shutdown(); |
713 |
| - } |
714 |
| - |
715 | 670 | @Override
|
716 | 671 | public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
|
717 | 672 | if (holder instanceof ListViewHolder) {
|
|
0 commit comments