mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 02:38:58 +03:00
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:
parent
81681f495a
commit
5ca5555fe6
1 changed files with 37 additions and 31 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue