package com.owncloud.android.datamodel;
import java.io.File;
+import java.io.InputStream;
import java.lang.ref.WeakReference;
import org.apache.commons.httpclient.HttpStatus;
private FileDataStorageManager mStorageManager;
- public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager, Account account) {
+ public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
+ Account account) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<ImageView>(imageView);
if (storageManager == null)
AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());
mServerVersion = accountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION);
- OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, MainApp.getAppContext());
+ OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount,
+ MainApp.getAppContext());
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext());
}
// Download thumbnail from server
if (mClient != null && mServerVersion != null) {
OwnCloudVersion serverOCVersion = new OwnCloudVersion(mServerVersion);
- if (serverOCVersion.compareTo(new OwnCloudVersion(MINOR_SERVER_VERSION_FOR_THUMBS)) >= 0) {
+ if (serverOCVersion.compareTo(
+ new OwnCloudVersion(MINOR_SERVER_VERSION_FOR_THUMBS)) >= 0) {
try {
int status = -1;
- String uri = mClient.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" +
+ String uri = mClient.getBaseUri() + "" +
+ "/index.php/apps/files/api/v1/thumbnail/" +
px + "/" + px + Uri.encode(file.getRemotePath(), "/");
Log_OC.d("Thumbnail", "URI: " + uri);
GetMethod get = new GetMethod(uri);
status = mClient.executeMethod(get);
if (status == HttpStatus.SC_OK) {
- byte[] bytes = get.getResponseBody();
- Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
+// byte[] bytes = get.getResponseBody();
+// Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0,
+// bytes.length);
+ InputStream inputStream = get.getResponseBodyAsStream();
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
// Add thumbnail to cache