X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/1bee51d2636615e25e74c65af838b89b3d68342a..refs/heads/master:/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 ab0743a9..4ad73173 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -195,10 +195,6 @@ public class ThumbnailsCacheManager { } protected void onPostExecute(Bitmap bitmap){ - if (isCancelled()) { - bitmap = null; - } - if (bitmap != null) { final ImageView imageView = mImageViewReference.get(); final ThumbnailGenerationTask bitmapWorkerTask = getBitmapWorkerTask(imageView); @@ -282,12 +278,13 @@ public class ThumbnailsCacheManager { OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount); if (mClient != null && serverOCVersion != null) { if (serverOCVersion.supportsRemoteThumbnails()) { + GetMethod get = null; try { 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); + get = new GetMethod(uri); int status = mClient.executeMethod(get); if (status == HttpStatus.SC_OK) { InputStream inputStream = get.getResponseBodyAsStream(); @@ -303,9 +300,15 @@ public class ThumbnailsCacheManager { if (thumbnail != null) { addBitmapToCache(imageKey, thumbnail); } + } else { + mClient.exhaustResponse(get.getResponseBodyAsStream()); } } catch (Exception e) { e.printStackTrace(); + } finally { + if (get != null) { + get.releaseConnection(); + } } } else { Log_OC.d(TAG, "Server too old"); @@ -365,6 +368,7 @@ public class ThumbnailsCacheManager { if (bitmapData == null || bitmapData != file) { // Cancel previous task bitmapWorkerTask.cancel(true); + Log_OC.v(TAG, "Cancelled generation of thumbnail for a reused imageView"); } else { // The same work is already in progress return false;