diff --git a/src/main/java/com/owncloud/android/providers/DiskLruImageCacheFileProvider.java b/src/main/java/com/owncloud/android/providers/DiskLruImageCacheFileProvider.java index 2c31422a81..974c1afb81 100644 --- a/src/main/java/com/owncloud/android/providers/DiskLruImageCacheFileProvider.java +++ b/src/main/java/com/owncloud/android/providers/DiskLruImageCacheFileProvider.java @@ -70,15 +70,17 @@ public class DiskLruImageCacheFileProvider extends ContentProvider { @Override public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException { - OCFile ocFile = getFile(uri); + return getParcelFileDescriptorForOCFile(getFile(uri)); + } + public static ParcelFileDescriptor getParcelFileDescriptorForOCFile(OCFile ocFile) throws FileNotFoundException { Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( - String.valueOf(ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + ocFile.getRemoteId())); + ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + ocFile.getRemoteId()); // fallback to thumbnail if (thumbnail == null) { thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( - String.valueOf(ThumbnailsCacheManager.PREFIX_THUMBNAIL + ocFile.getRemoteId())); + ThumbnailsCacheManager.PREFIX_THUMBNAIL + ocFile.getRemoteId()); } // fallback to default image diff --git a/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java b/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java index c1afcd2d8a..3ed6d8ab20 100644 --- a/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java +++ b/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java @@ -76,7 +76,6 @@ import com.owncloud.android.operations.SynchronizeFileOperation; import com.owncloud.android.ui.activity.SettingsActivity; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.MimeTypeUtil; -import com.owncloud.android.utils.UriUtils; import org.nextcloud.providers.cursors.FileCursor; import org.nextcloud.providers.cursors.RootCursor; @@ -312,19 +311,18 @@ public class DocumentsStorageProvider extends DocumentsProvider { throw new FileNotFoundException("Context may not be null!"); } - Document document = toDocument(documentId); + OCFile file = toDocument(documentId).getFile(); boolean exists = ThumbnailsCacheManager.containsBitmap(ThumbnailsCacheManager.PREFIX_THUMBNAIL - + document.getFile().getRemoteId()); + + file.getRemoteId()); if (!exists) { - ThumbnailsCacheManager.generateThumbnailFromOCFile(document.getFile()); + ThumbnailsCacheManager.generateThumbnailFromOCFile(file); } - Uri uri = Uri.parse(UriUtils.URI_CONTENT_SCHEME + context.getResources().getString( - R.string.image_cache_provider_authority) + document.getRemotePath()); - Log.d(TAG, "open thumbnail, uri=" + uri); - return context.getContentResolver().openAssetFileDescriptor(uri, "r"); + return new AssetFileDescriptor(DiskLruImageCacheFileProvider.getParcelFileDescriptorForOCFile(file), + 0, + file.getFileLength()); } @Override