If no thumbnail exists, check if resized version exist and generate thumbnail out of it

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2018-02-15 14:17:14 +01:00
parent 81681f495a
commit 5ca5555fe6
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -528,10 +528,16 @@ public class ThumbnailsCacheManager {
mStorageManager.saveFile(file); mStorageManager.saveFile(file);
} }
} else {
// check if resized version is available
String resizedImageKey = PREFIX_RESIZED_IMAGE + String.valueOf(file.getRemoteId());
Bitmap resizedImage = getBitmapFromDiskCache(resizedImageKey);
if (resizedImage != null) {
thumbnail = ThumbnailUtils.extractThumbnail(resizedImage, pxW, pxH);
} else { } else {
//Download thumbnail from server //Download thumbnail from server
OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount); OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount);
if (mClient != null) { if (mClient != null) {
if (serverOCVersion.supportsRemoteThumbnails()) { if (serverOCVersion.supportsRemoteThumbnails()) {
getMethod = null; getMethod = null;
@ -561,13 +567,6 @@ public class ThumbnailsCacheManager {
if (file.getMimetype().equalsIgnoreCase(PNG_MIMETYPE)) { if (file.getMimetype().equalsIgnoreCase(PNG_MIMETYPE)) {
thumbnail = handlePNG(thumbnail, pxW, pxH); thumbnail = handlePNG(thumbnail, pxW, pxH);
} }
// Add thumbnail to cache
if (thumbnail != null) {
Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName());
addBitmapToCache(imageKey, thumbnail);
}
} catch (Exception e) { } catch (Exception e) {
Log_OC.d(TAG, e.getMessage(), e); Log_OC.d(TAG, e.getMessage(), e);
} finally { } finally {
@ -580,6 +579,13 @@ public class ThumbnailsCacheManager {
} }
} }
} }
// Add thumbnail to cache
if (thumbnail != null) {
Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName());
addBitmapToCache(imageKey, thumbnail);
}
}
} }
return thumbnail; return thumbnail;