mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 06:35:48 +03:00
Merge pull request #6886 from nextcloud/docImage
DocumentsStorageProvider: open thumbnail directly
This commit is contained in:
commit
51cf63b79b
2 changed files with 11 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue