- 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);
- int status = mClient.executeMethod(get);
- if (status == HttpStatus.SC_OK) {
-// 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
- if (thumbnail != null) {
- addBitmapToCache(imageKey, thumbnail);
+ if (mIsThumbnail) {
+ String uri = mClient.getBaseUri() + "" +
+ "/index.php/apps/files/api/v1/thumbnail/" +
+ pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");
+ Log_OC.d("Thumbnail", "Download URI: " + uri);
+ GetMethod get = new GetMethod(uri);
+ int status = mClient.executeMethod(get);
+ if (status == HttpStatus.SC_OK) {
+ InputStream inputStream = get.getResponseBodyAsStream();
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
+ thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
+ } else {
+ Log_OC.d(TAG, "Status: " + status);
+ }
+ } else {
+ String gallery = "";
+ if (serverOCVersion.supportsNativeGallery()){
+ gallery = "gallery";
+ } else {
+ gallery = "galleryplus";
+ }
+
+ String uri = mClient.getBaseUri() +
+ "/index.php/apps/" + gallery + "/api/preview/" + Integer.parseInt(file.getRemoteId().substring(0,8)) +
+ "/" + pxW + "/" + pxH;
+ Log_OC.d("Thumbnail", "FileName: " + file.getFileName() + " Download URI: " + uri);
+ GetMethod get = new GetMethod(uri);
+ int status = mClient.executeMethod(get);
+ if (status == HttpStatus.SC_OK) {
+ InputStream inputStream = get.getResponseBodyAsStream();
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
+ // Download via gallery app
+ thumbnail = bitmap;