|
63 | 63 |
|
64 | 64 | import java.io.File; |
65 | 65 | import java.io.FileNotFoundException; |
66 | | -import java.io.IOException; |
67 | 66 | import java.io.InputStream; |
68 | 67 | import java.lang.ref.WeakReference; |
69 | 68 | import java.util.List; |
@@ -104,6 +103,7 @@ public final class ThumbnailsCacheManager { |
104 | 103 | private static final int mCompressQuality = 70; |
105 | 104 | private static OwnCloudClient mClient; |
106 | 105 | private static final int THUMBNAIL_SIZE_IN_KB = 512; |
| 106 | + private static final int RESIZED_IMAGE_SIZE_IN_KB = 10240; |
107 | 107 |
|
108 | 108 | public static final Bitmap mDefaultImg = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(), |
109 | 109 | R.drawable.file_image); |
@@ -240,9 +240,17 @@ public static void addBitmapToCache(String key, Bitmap bitmap) { |
240 | 240 | return; |
241 | 241 | } |
242 | 242 |
|
243 | | - if (BitmapExtensionsKt.allocationKilobyte(bitmap) > THUMBNAIL_SIZE_IN_KB) { |
| 243 | + // do not scale down resized images |
| 244 | + int size; |
| 245 | + if (key.startsWith("r")) { |
| 246 | + size = RESIZED_IMAGE_SIZE_IN_KB; |
| 247 | + } else { |
| 248 | + size = THUMBNAIL_SIZE_IN_KB; |
| 249 | + } |
| 250 | + |
| 251 | + if (BitmapExtensionsKt.allocationKilobyte(bitmap) > size) { |
244 | 252 | Log_OC.d(TAG, "Scaling bitmap before caching: " + key); |
245 | | - bitmap = BitmapExtensionsKt.scaleUntil(bitmap, THUMBNAIL_SIZE_IN_KB); |
| 253 | + bitmap = BitmapExtensionsKt.scaleUntil(bitmap, size); |
246 | 254 | } |
247 | 255 |
|
248 | 256 | mThumbnailCache.put(key, bitmap); |
|
0 commit comments