|
@@ -62,6 +62,7 @@ import com.owncloud.android.ui.adapter.DiskLruImageCache;
|
|
|
import com.owncloud.android.ui.fragment.FileFragment;
|
|
|
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
|
|
import com.owncloud.android.utils.BitmapUtils;
|
|
|
+import com.owncloud.android.utils.DisplayUtils;
|
|
|
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener;
|
|
|
import com.owncloud.android.utils.FileStorageUtils;
|
|
|
import com.owncloud.android.utils.MimeTypeUtil;
|
|
@@ -79,6 +80,7 @@ import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
+import androidx.annotation.VisibleForTesting;
|
|
|
import androidx.core.content.res.ResourcesCompat;
|
|
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
|
|
|
@@ -251,6 +253,164 @@ public final class ThumbnailsCacheManager {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public static class GalleryImageGenerationTaskObject {
|
|
|
+ private final OCFile file;
|
|
|
+ private final String imageKey;
|
|
|
+
|
|
|
+ public GalleryImageGenerationTaskObject(OCFile file, String imageKey) {
|
|
|
+ this.file = file;
|
|
|
+ this.imageKey = imageKey;
|
|
|
+ }
|
|
|
+
|
|
|
+ private OCFile getFile() {
|
|
|
+ return file;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getImageKey() {
|
|
|
+ return imageKey;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static class GalleryImageGenerationTask extends AsyncTask<Object, Void, Bitmap> {
|
|
|
+ private final User user;
|
|
|
+ private final FileDataStorageManager storageManager;
|
|
|
+ private final WeakReference<ImageView> imageViewReference;
|
|
|
+ private OCFile file;
|
|
|
+ private String imageKey;
|
|
|
+ private GalleryListener listener;
|
|
|
+ private List<GalleryImageGenerationTask> asyncTasks;
|
|
|
+ private int backgroundColor;
|
|
|
+ private boolean newImage = false;
|
|
|
+
|
|
|
+ public GalleryImageGenerationTask(
|
|
|
+ ImageView imageView,
|
|
|
+ User user,
|
|
|
+ FileDataStorageManager storageManager,
|
|
|
+ List<GalleryImageGenerationTask> asyncTasks,
|
|
|
+ String imageKey,
|
|
|
+ int backgroundColor
|
|
|
+ ) {
|
|
|
+ this.user = user;
|
|
|
+ this.storageManager = storageManager;
|
|
|
+ imageViewReference = new WeakReference<>(imageView);
|
|
|
+ this.asyncTasks = asyncTasks;
|
|
|
+ this.imageKey = imageKey;
|
|
|
+ this.backgroundColor = backgroundColor;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setListener(GalleryImageGenerationTask.GalleryListener listener) {
|
|
|
+ this.listener = listener;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getImageKey() {
|
|
|
+ return imageKey;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Bitmap doInBackground(Object... params) {
|
|
|
+ Bitmap thumbnail;
|
|
|
+
|
|
|
+ file = (OCFile) params[0];
|
|
|
+
|
|
|
+// try {
|
|
|
+// Thread.sleep(10000);
|
|
|
+// } catch (InterruptedException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+
|
|
|
+ if (file.getRemoteId() != null && file.isPreviewAvailable()) {
|
|
|
+ // Thumbnail in cache?
|
|
|
+ thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
|
|
+ ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + file.getRemoteId()
|
|
|
+ );
|
|
|
+
|
|
|
+ if (thumbnail != null && !file.isUpdateThumbnailNeeded()) {
|
|
|
+ Float size = (float) ThumbnailsCacheManager.getThumbnailDimension();
|
|
|
+
|
|
|
+ // resized dimensions
|
|
|
+ ImageDimension imageDimension = file.getImageDimension();
|
|
|
+ if (imageDimension == null ||
|
|
|
+ imageDimension.getWidth() != size ||
|
|
|
+ imageDimension.getHeight() != size) {
|
|
|
+ file.setImageDimension(new ImageDimension(thumbnail.getWidth(), thumbnail.getHeight()));
|
|
|
+ storageManager.saveFile(file);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (MimeTypeUtil.isVideo(file)) {
|
|
|
+ return ThumbnailsCacheManager.addVideoOverlay(thumbnail, MainApp.getAppContext());
|
|
|
+ } else {
|
|
|
+ return thumbnail;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ mClient = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(user.toOwnCloudAccount(),
|
|
|
+ MainApp.getAppContext());
|
|
|
+
|
|
|
+ thumbnail = doResizedImageInBackground(file, storageManager);
|
|
|
+ newImage = true;
|
|
|
+
|
|
|
+ if (MimeTypeUtil.isVideo(file) && thumbnail != null) {
|
|
|
+ thumbnail = addVideoOverlay(thumbnail, MainApp.getAppContext());
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (OutOfMemoryError oome) {
|
|
|
+ Log_OC.e(TAG, "Out of memory");
|
|
|
+ } catch (Throwable t) {
|
|
|
+ // the app should never break due to a problem with thumbnails
|
|
|
+ Log_OC.e(TAG, "Generation of gallery image for " + file + " failed", t);
|
|
|
+ }
|
|
|
+
|
|
|
+ return thumbnail;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void onPostExecute(Bitmap bitmap) {
|
|
|
+ if (bitmap != null && imageViewReference != null) {
|
|
|
+ final ImageView imageView = imageViewReference.get();
|
|
|
+ final GalleryImageGenerationTask bitmapWorkerTask = getGalleryImageGenerationTask(imageView);
|
|
|
+
|
|
|
+ if (this == bitmapWorkerTask) {
|
|
|
+ String tagId = String.valueOf(file.getFileId());
|
|
|
+
|
|
|
+ if (String.valueOf(imageView.getTag()).equals(tagId)) {
|
|
|
+ if ("image/png".equalsIgnoreCase(file.getMimeType())) {
|
|
|
+ imageView.setBackgroundColor(backgroundColor);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (newImage && listener != null) {
|
|
|
+ listener.onNewGalleryImage();
|
|
|
+ }
|
|
|
+ imageView.setImageBitmap(bitmap);
|
|
|
+ imageView.invalidate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (listener != null) {
|
|
|
+ listener.onSuccess();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (listener != null) {
|
|
|
+ listener.onError();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (asyncTasks != null) {
|
|
|
+ asyncTasks.remove(this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public interface GalleryListener {
|
|
|
+ void onSuccess();
|
|
|
+
|
|
|
+ void onNewGalleryImage();
|
|
|
+
|
|
|
+ void onError();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static class ResizedImageGenerationTask extends AsyncTask<Object, Void, Bitmap> {
|
|
|
private final FileFragment fileFragment;
|
|
|
private final FileDataStorageManager storageManager;
|
|
@@ -288,10 +448,10 @@ public final class ThumbnailsCacheManager {
|
|
|
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(user.toOwnCloudAccount(),
|
|
|
MainApp.getAppContext());
|
|
|
|
|
|
- thumbnail = doResizedImageInBackground();
|
|
|
+ thumbnail = doResizedImageInBackground(file, storageManager);
|
|
|
|
|
|
if (MimeTypeUtil.isVideo(file) && thumbnail != null) {
|
|
|
- thumbnail = addVideoOverlay(thumbnail);
|
|
|
+ thumbnail = addVideoOverlay(thumbnail, MainApp.getAppContext());
|
|
|
}
|
|
|
|
|
|
} catch (OutOfMemoryError oome) {
|
|
@@ -304,79 +464,6 @@ public final class ThumbnailsCacheManager {
|
|
|
return thumbnail;
|
|
|
}
|
|
|
|
|
|
- private Bitmap doResizedImageInBackground() {
|
|
|
- Bitmap thumbnail;
|
|
|
-
|
|
|
- String imageKey = PREFIX_RESIZED_IMAGE + file.getRemoteId();
|
|
|
-
|
|
|
- // Check disk cache in background thread
|
|
|
- thumbnail = getBitmapFromDiskCache(imageKey);
|
|
|
-
|
|
|
- // Not found in disk cache
|
|
|
- if (thumbnail == null || file.isUpdateThumbnailNeeded()) {
|
|
|
- Point p = getScreenDimension();
|
|
|
- int pxW = p.x;
|
|
|
- int pxH = p.y;
|
|
|
-
|
|
|
- if (file.isDown()) {
|
|
|
- Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getStoragePath(), pxW, pxH);
|
|
|
-
|
|
|
- if (bitmap != null) {
|
|
|
- // Handle PNG
|
|
|
- if (PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
|
|
|
- bitmap = handlePNG(bitmap, pxW, pxH);
|
|
|
- }
|
|
|
-
|
|
|
- thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), pxW, pxH);
|
|
|
-
|
|
|
- file.setUpdateThumbnailNeeded(false);
|
|
|
- storageManager.saveFile(file);
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- // Download thumbnail from server
|
|
|
- if (mClient != null) {
|
|
|
- GetMethod getMethod = null;
|
|
|
- try {
|
|
|
- String uri = mClient.getBaseUri() + "/index.php/core/preview.png?file="
|
|
|
- + URLEncoder.encode(file.getRemotePath())
|
|
|
- + "&x=" + pxW + "&y=" + pxH + "&a=1&mode=cover&forceIcon=0";
|
|
|
- getMethod = new GetMethod(uri);
|
|
|
-
|
|
|
- int status = mClient.executeMethod(getMethod);
|
|
|
- if (status == HttpStatus.SC_OK) {
|
|
|
- InputStream inputStream = getMethod.getResponseBodyAsStream();
|
|
|
- thumbnail = BitmapFactory.decodeStream(inputStream);
|
|
|
- } else {
|
|
|
- mClient.exhaustResponse(getMethod.getResponseBodyAsStream());
|
|
|
- }
|
|
|
-
|
|
|
- // Handle PNG
|
|
|
- if (thumbnail != null && PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
|
|
|
- thumbnail = handlePNG(thumbnail, thumbnail.getWidth(), thumbnail.getHeight());
|
|
|
- }
|
|
|
-
|
|
|
- // Add thumbnail to cache
|
|
|
- if (thumbnail != null) {
|
|
|
- Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName());
|
|
|
- addBitmapToCache(imageKey, thumbnail);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- Log_OC.d(TAG, e.getMessage(), e);
|
|
|
- } finally {
|
|
|
- if (getMethod != null) {
|
|
|
- getMethod.releaseConnection();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return thumbnail;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
protected void onPostExecute(Bitmap bitmap) {
|
|
|
if (imageViewReference != null) {
|
|
|
final ImageView imageView = imageViewReference.get();
|
|
@@ -516,7 +603,7 @@ public final class ThumbnailsCacheManager {
|
|
|
thumbnail = doThumbnailFromOCFileInBackground();
|
|
|
|
|
|
if (MimeTypeUtil.isVideo((ServerFileInterface) mFile) && thumbnail != null) {
|
|
|
- thumbnail = addVideoOverlay(thumbnail);
|
|
|
+ thumbnail = addVideoOverlay(thumbnail, MainApp.getAppContext());
|
|
|
}
|
|
|
} else if (mFile instanceof File) {
|
|
|
thumbnail = doFileInBackground();
|
|
@@ -525,7 +612,7 @@ public final class ThumbnailsCacheManager {
|
|
|
String mMimeType = FileStorageUtils.getMimeTypeFromName(url);
|
|
|
|
|
|
if (MimeTypeUtil.isVideo(mMimeType) && thumbnail != null) {
|
|
|
- thumbnail = addVideoOverlay(thumbnail);
|
|
|
+ thumbnail = addVideoOverlay(thumbnail, MainApp.getAppContext());
|
|
|
}
|
|
|
//} else { do nothing
|
|
|
}
|
|
@@ -1101,22 +1188,31 @@ public final class ThumbnailsCacheManager {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public static Bitmap addVideoOverlay(Bitmap thumbnail) {
|
|
|
- int playButtonWidth = (int) (thumbnail.getWidth() * 0.3);
|
|
|
- int playButtonHeight = (int) (thumbnail.getHeight() * 0.3);
|
|
|
+ private static GalleryImageGenerationTask getGalleryImageGenerationTask(ImageView imageView) {
|
|
|
+ if (imageView != null) {
|
|
|
+ final Drawable drawable = imageView.getDrawable();
|
|
|
+ if (drawable instanceof AsyncGalleryImageDrawable) {
|
|
|
+ final AsyncGalleryImageDrawable asyncDrawable = (AsyncGalleryImageDrawable) drawable;
|
|
|
+ return asyncDrawable.getBitmapWorkerTask();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Bitmap addVideoOverlay(Bitmap thumbnail, Context context) {
|
|
|
+// int minValue = Math.min(thumbnail.getWidth(), thumbnail.getHeight());
|
|
|
+// int playButtonWidth = (int) (minValue * 0.2);
|
|
|
+// int playButtonHeight = (int) (minValue * 0.2);
|
|
|
|
|
|
Drawable playButtonDrawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(),
|
|
|
- R.drawable.view_play,
|
|
|
+ R.drawable.video_white,
|
|
|
null);
|
|
|
|
|
|
- Bitmap playButton = BitmapUtils.drawableToBitmap(playButtonDrawable,
|
|
|
- playButtonWidth,
|
|
|
- playButtonHeight);
|
|
|
+ int px = DisplayUtils.convertDpToPixel(24f, context);
|
|
|
+
|
|
|
+ Bitmap playButton = BitmapUtils.drawableToBitmap(playButtonDrawable, px, px);
|
|
|
|
|
|
- Bitmap resizedPlayButton = Bitmap.createScaledBitmap(playButton,
|
|
|
- playButtonWidth,
|
|
|
- playButtonHeight,
|
|
|
- true);
|
|
|
+ Bitmap resizedPlayButton = Bitmap.createScaledBitmap(playButton, px, px, true);
|
|
|
|
|
|
Bitmap resultBitmap = Bitmap.createBitmap(thumbnail.getWidth(),
|
|
|
thumbnail.getHeight(),
|
|
@@ -1124,32 +1220,31 @@ public final class ThumbnailsCacheManager {
|
|
|
|
|
|
Canvas c = new Canvas(resultBitmap);
|
|
|
|
|
|
- // compute visual center of play button, according to resized image
|
|
|
- int x1 = resizedPlayButton.getWidth();
|
|
|
- int y1 = resizedPlayButton.getHeight() / 2;
|
|
|
- int x2 = 0;
|
|
|
- int y2 = resizedPlayButton.getWidth();
|
|
|
- int x3 = 0;
|
|
|
- int y3 = 0;
|
|
|
-
|
|
|
- double ym = ( ((Math.pow(x3,2) - Math.pow(x1,2) + Math.pow(y3,2) - Math.pow(y1,2)) *
|
|
|
- (x2 - x1)) - (Math.pow(x2,2) - Math.pow(x1,2) + Math.pow(y2,2) -
|
|
|
- Math.pow(y1,2)) * (x3 - x1) ) / (2 * ( ((y3 - y1) * (x2 - x1)) -
|
|
|
- ((y2 - y1) * (x3 - x1)) ));
|
|
|
- double xm = ( (Math.pow(x2,2) - Math.pow(x1,2)) + (Math.pow(y2,2) - Math.pow(y1,2)) -
|
|
|
- (2*ym*(y2 - y1)) ) / (2*(x2 - x1));
|
|
|
-
|
|
|
- // offset to top left
|
|
|
- double ox = - xm;
|
|
|
-
|
|
|
+// // compute visual center of play button, according to resized image
|
|
|
+// int x1 = resizedPlayButton.getWidth();
|
|
|
+// int y1 = resizedPlayButton.getHeight() / 2;
|
|
|
+// int x2 = 0;
|
|
|
+// int y2 = resizedPlayButton.getWidth();
|
|
|
+// int x3 = 0;
|
|
|
+// int y3 = 0;
|
|
|
+//
|
|
|
+// double ym = ( ((Math.pow(x3,2) - Math.pow(x1,2) + Math.pow(y3,2) - Math.pow(y1,2)) *
|
|
|
+// (x2 - x1)) - (Math.pow(x2,2) - Math.pow(x1,2) + Math.pow(y2,2) -
|
|
|
+// Math.pow(y1,2)) * (x3 - x1) ) / (2 * ( ((y3 - y1) * (x2 - x1)) -
|
|
|
+// ((y2 - y1) * (x3 - x1)) ));
|
|
|
+// double xm = ( (Math.pow(x2,2) - Math.pow(x1,2)) + (Math.pow(y2,2) - Math.pow(y1,2)) -
|
|
|
+// (2*ym*(y2 - y1)) ) / (2*(x2 - x1));
|
|
|
+//
|
|
|
+// // offset to top left
|
|
|
+// double ox = - xm;
|
|
|
+//
|
|
|
|
|
|
c.drawBitmap(thumbnail, 0, 0, null);
|
|
|
|
|
|
Paint p = new Paint();
|
|
|
p.setAlpha(230);
|
|
|
|
|
|
- c.drawBitmap(resizedPlayButton, (float) ((thumbnail.getWidth() / 2) + ox),
|
|
|
- (float) ((thumbnail.getHeight() / 2) - ym), p);
|
|
|
+ c.drawBitmap(resizedPlayButton, px, px, p);
|
|
|
|
|
|
return resultBitmap;
|
|
|
}
|
|
@@ -1183,6 +1278,19 @@ public final class ThumbnailsCacheManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static class AsyncGalleryImageDrawable extends BitmapDrawable {
|
|
|
+ private final WeakReference<GalleryImageGenerationTask> bitmapWorkerTaskReference;
|
|
|
+
|
|
|
+ public AsyncGalleryImageDrawable(Resources res, Bitmap bitmap, GalleryImageGenerationTask bitmapWorkerTask) {
|
|
|
+ super(res, bitmap);
|
|
|
+ bitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask);
|
|
|
+ }
|
|
|
+
|
|
|
+ private GalleryImageGenerationTask getBitmapWorkerTask() {
|
|
|
+ return bitmapWorkerTaskReference.get();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static class AsyncMediaThumbnailDrawable extends BitmapDrawable {
|
|
|
|
|
|
public AsyncMediaThumbnailDrawable(Resources res, Bitmap bitmap) {
|
|
@@ -1291,4 +1399,87 @@ public final class ThumbnailsCacheManager {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @VisibleForTesting
|
|
|
+ public static void clearCache() {
|
|
|
+ mThumbnailCache.clearCache();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageManager storageManager) {
|
|
|
+ Bitmap thumbnail;
|
|
|
+
|
|
|
+ String imageKey = PREFIX_RESIZED_IMAGE + file.getRemoteId();
|
|
|
+
|
|
|
+ // Check disk cache in background thread
|
|
|
+ thumbnail = getBitmapFromDiskCache(imageKey);
|
|
|
+
|
|
|
+ // Not found in disk cache
|
|
|
+ if (thumbnail == null || file.isUpdateThumbnailNeeded()) {
|
|
|
+ Point p = getScreenDimension();
|
|
|
+ int pxW = p.x;
|
|
|
+ int pxH = p.y;
|
|
|
+
|
|
|
+ if (file.isDown()) {
|
|
|
+ Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getStoragePath(), pxW, pxH);
|
|
|
+
|
|
|
+ if (bitmap != null) {
|
|
|
+ // Handle PNG
|
|
|
+ if (PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
|
|
|
+ bitmap = handlePNG(bitmap, pxW, pxH);
|
|
|
+ }
|
|
|
+
|
|
|
+ thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), pxW, pxH);
|
|
|
+
|
|
|
+ file.setUpdateThumbnailNeeded(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // Download thumbnail from server
|
|
|
+ if (mClient != null) {
|
|
|
+ GetMethod getMethod = null;
|
|
|
+ try {
|
|
|
+ String uri = mClient.getBaseUri() + "/index.php/core/preview.png?file="
|
|
|
+ + URLEncoder.encode(file.getRemotePath())
|
|
|
+ + "&x=" + (pxW / 2) + "&y=" + (pxH / 2) + "&a=1&mode=cover&forceIcon=0";
|
|
|
+ Log_OC.d(TAG, "generate resized image: " + file.getFileName() + " URI: " + uri);
|
|
|
+ getMethod = new GetMethod(uri);
|
|
|
+
|
|
|
+ int status = mClient.executeMethod(getMethod);
|
|
|
+ if (status == HttpStatus.SC_OK) {
|
|
|
+ InputStream inputStream = getMethod.getResponseBodyAsStream();
|
|
|
+ thumbnail = BitmapFactory.decodeStream(inputStream);
|
|
|
+ } else {
|
|
|
+ mClient.exhaustResponse(getMethod.getResponseBodyAsStream());
|
|
|
+ }
|
|
|
+
|
|
|
+ // Handle PNG
|
|
|
+ if (thumbnail != null && PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
|
|
|
+ thumbnail = handlePNG(thumbnail, thumbnail.getWidth(), thumbnail.getHeight());
|
|
|
+ }
|
|
|
+
|
|
|
+ // Add thumbnail to cache
|
|
|
+ if (thumbnail != null) {
|
|
|
+ Log_OC.d(TAG, "add resized image to cache: " + file.getFileName());
|
|
|
+ addBitmapToCache(imageKey, thumbnail);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ Log_OC.d(TAG, e.getMessage(), e);
|
|
|
+ } finally {
|
|
|
+ if (getMethod != null) {
|
|
|
+ getMethod.releaseConnection();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // resized dimensions
|
|
|
+ if (thumbnail != null) {
|
|
|
+ file.setImageDimension(new ImageDimension(thumbnail.getWidth(), thumbnail.getHeight()));
|
|
|
+ storageManager.saveFile(file);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return thumbnail;
|
|
|
+ }
|
|
|
}
|