Merge branch 'develop2' into imageGrid2
[pub/Android/ownCloud.git] / src / com / owncloud / android / datamodel / ThumbnailsCacheManager.java
index edab29d..eeb0182 100644 (file)
@@ -173,6 +173,25 @@ public class ThumbnailsCacheManager {
                 }
 
                 mFile = params[0];
+                final String imageKey = String.valueOf(mFile.getRemoteId());
+    
+                // Check disk cache in background thread
+                thumbnail = getBitmapFromDiskCache(imageKey);
+    
+                // Not found in disk cache
+                if (thumbnail == null || mFile.needsUpdateThumbnail()) { 
+                    // Use Width of imageView -> no blurry images on big screens
+                    int px = mImageViewReference.get().getWidth();
+                    
+                    if (mFile.isDown()){
+                        Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
+                                mFile.getStoragePath(), px, px);
+                        
+                        if (bitmap != null) {
+                            thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
+    
+                            // Add thumbnail to cache
+                            addBitmapToCache(imageKey, thumbnail);
 
                 if (mFile instanceof OCFile) {
                     thumbnail = doOCFileInBackground();