projects
/
pub
/
Android
/
ownCloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into create_folder_during_upload_pr_701_with_develop
[pub/Android/ownCloud.git]
/
src
/
com
/
owncloud
/
android
/
datamodel
/
ThumbnailsCacheManager.java
diff --git
a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
index
3083d7e
..
87fa43f
100644
(file)
--- a/
src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
+++ b/
src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java
@@
-1,5
+1,9
@@
-/* ownCloud Android client application
- * Copyright (C) 2012-2014 ownCloud Inc.
+/**
+ * ownCloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * @author David A. Velasco
+ * Copyright (C) 2015 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@@
-49,10
+53,7
@@
import com.owncloud.android.utils.BitmapUtils;
import com.owncloud.android.utils.DisplayUtils;
/**
import com.owncloud.android.utils.DisplayUtils;
/**
- * Manager for concurrent access to thumbnails cache.
- *
- * @author Tobias Kaminsky
- * @author David A. Velasco
+ * Manager for concurrent access to thumbnails cache.
*/
public class ThumbnailsCacheManager {
*/
public class ThumbnailsCacheManager {
@@
-173,7
+174,7
@@
public class ThumbnailsCacheManager {
}
mFile = params[0];
}
mFile = params[0];
-
+
if (mFile instanceof OCFile) {
thumbnail = doOCFileInBackground();
} else if (mFile instanceof File) {
if (mFile instanceof OCFile) {
thumbnail = doOCFileInBackground();
} else if (mFile instanceof File) {
@@
-243,31
+244,32
@@
public class ThumbnailsCacheManager {
private int getThumbnailDimension(){
// Converts dp to pixel
Resources r = MainApp.getAppContext().getResources();
private int getThumbnailDimension(){
// Converts dp to pixel
Resources r = MainApp.getAppContext().getResources();
- return (int) Math.round(r.getDimension(R.dimen.file_icon_size));
+ return (int) Math.round(r.getDimension(R.dimen.file_icon_size
_grid
));
}
private Bitmap doOCFileInBackground() {
Bitmap thumbnail = null;
}
private Bitmap doOCFileInBackground() {
Bitmap thumbnail = null;
+ OCFile file = (OCFile)mFile;
- final String imageKey = String.valueOf(
((OCFile) mFile)
.getRemoteId());
+ final String imageKey = String.valueOf(
file
.getRemoteId());
// Check disk cache in background thread
thumbnail = getBitmapFromDiskCache(imageKey);
// Not found in disk cache
// Check disk cache in background thread
thumbnail = getBitmapFromDiskCache(imageKey);
// Not found in disk cache
- if (thumbnail == null ||
((OCFile)mFile)
.needsUpdateThumbnail()) {
+ if (thumbnail == null ||
file
.needsUpdateThumbnail()) {
int px = getThumbnailDimension();
int px = getThumbnailDimension();
- if (
((OCFile)mFile)
.isDown()) {
+ if (
file
.isDown()) {
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
-
((OCFile)mFile)
.getStoragePath(), px, px);
+
file
.getStoragePath(), px, px);
if (bitmap != null) {
if (bitmap != null) {
- thumbnail = addThumbnailToCache(imageKey, bitmap,
((OCFile)mFile)
.getStoragePath(), px);
+ thumbnail = addThumbnailToCache(imageKey, bitmap,
file
.getStoragePath(), px);
-
((OCFile)mFile)
.setNeedsUpdateThumbnail(false);
- mStorageManager.saveFile(
((OCFile)mFile)
);
+
file
.setNeedsUpdateThumbnail(false);
+ mStorageManager.saveFile(
file
);
}
} else {
}
} else {
@@
-279,7
+281,7
@@
public class ThumbnailsCacheManager {
int status = -1;
String uri = mClient.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" +
int status = -1;
String uri = mClient.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" +
- px + "/" + px + Uri.encode(
((OCFile)mFile)
.getRemotePath(), "/");
+ px + "/" + px + Uri.encode(
file
.getRemotePath(), "/");
Log_OC.d("Thumbnail", "URI: " + uri);
GetMethod get = new GetMethod(uri);
status = mClient.executeMethod(get);
Log_OC.d("Thumbnail", "URI: " + uri);
GetMethod get = new GetMethod(uri);
status = mClient.executeMethod(get);
@@
-309,7
+311,9
@@
public class ThumbnailsCacheManager {
private Bitmap doFileInBackground() {
Bitmap thumbnail = null;
private Bitmap doFileInBackground() {
Bitmap thumbnail = null;
- final String imageKey = String.valueOf(mFile.hashCode());
+ File file = (File)mFile;
+
+ final String imageKey = String.valueOf(file.hashCode());
// Check disk cache in background thread
thumbnail = getBitmapFromDiskCache(imageKey);
// Check disk cache in background thread
thumbnail = getBitmapFromDiskCache(imageKey);
@@
-320,10
+324,10
@@
public class ThumbnailsCacheManager {
int px = getThumbnailDimension();
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
int px = getThumbnailDimension();
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
-
((File)mFile)
.getAbsolutePath(), px, px);
+
file
.getAbsolutePath(), px, px);
if (bitmap != null) {
if (bitmap != null) {
- thumbnail = addThumbnailToCache(imageKey, bitmap,
((File)mFile)
.getPath(), px);
+ thumbnail = addThumbnailToCache(imageKey, bitmap,
file
.getPath(), px);
}
}
return thumbnail;
}
}
return thumbnail;