浏览代码

round corners only in list view

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 5 年之前
父节点
当前提交
4fb140d275

+ 20 - 5
src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

@@ -410,12 +410,23 @@ public final class ThumbnailsCacheManager {
         private String mImageKey;
         private FileDataStorageManager mStorageManager;
         private GetMethod getMethod;
+        private boolean roundedCorners = false;
 
         public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager, Account account)
                 throws IllegalArgumentException {
             this(imageView, storageManager, account, null);
         }
 
+        public ThumbnailGenerationTask(ImageView imageView,
+                                       FileDataStorageManager storageManager,
+                                       Account account,
+                                       List<ThumbnailGenerationTask> asyncTasks,
+                                       boolean roundedCorners)
+            throws IllegalArgumentException {
+            this(imageView, storageManager, account, asyncTasks);
+            this.roundedCorners = roundedCorners;
+        }
+
         public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
                                        Account account, List<ThumbnailGenerationTask> asyncTasks)
                 throws IllegalArgumentException {
@@ -508,12 +519,16 @@ public final class ThumbnailsCacheManager {
                         tagId = String.valueOf(((TrashbinFile) mFile).getRemoteId());
                     }
                     if (String.valueOf(imageView.getTag()).equals(tagId)) {
-                        Resources resources = MainApp.getAppContext().getResources();
+                        if (roundedCorners) {
+                            Resources resources = MainApp.getAppContext().getResources();
 
-                        BitmapUtils.setRoundedBitmap(resources,
-                                                     bitmap,
-                                                     resources.getDimension(R.dimen.file_icon_rounded_corner_radius),
-                                                     imageView);
+                            BitmapUtils.setRoundedBitmap(resources,
+                                                         bitmap,
+                                                         resources.getDimension(R.dimen.file_icon_rounded_corner_radius),
+                                                         imageView);
+                        } else {
+                            imageView.setImageBitmap(bitmap);
+                        }
                     }
                 }
             }

+ 11 - 6
src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

@@ -603,12 +603,16 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
                         Bitmap withOverlay = ThumbnailsCacheManager.addVideoOverlay(thumbnail);
                         thumbnailView.setImageBitmap(withOverlay);
                     } else {
-                        Resources resources = MainApp.getAppContext().getResources();
+                        if (gridView) {
+                            thumbnailView.setImageBitmap(thumbnail);
+                        } else {
+                            Resources resources = MainApp.getAppContext().getResources();
 
-                        BitmapUtils.setRoundedBitmap(resources,
-                                                     thumbnail,
-                                                     resources.getDimension(R.dimen.file_icon_rounded_corner_radius),
-                                                     thumbnailView);
+                            BitmapUtils.setRoundedBitmap(resources,
+                                                         thumbnail,
+                                                         resources.getDimension(R.dimen.file_icon_rounded_corner_radius),
+                                                         thumbnailView);
+                        }
 
                     }
                 } else {
@@ -619,7 +623,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
                                 new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
                                                                                    mStorageManager,
                                                                                    user.toPlatformAccount(),
-                                                                                   asyncTasks);
+                                                                                   asyncTasks,
+                                                                                   !gridView);
 
                             if (thumbnail == null) {
                                 thumbnail = BitmapUtils.drawableToBitmap(