Ensure that encrypted thumbnails are loaded from network correctly
This commit is contained in:
parent
09dfe6676a
commit
0c8df6c923
2 changed files with 22 additions and 6 deletions
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:photos/core/cache/image_cache.dart';
|
||||
import 'package:photos/core/cache/thumbnail_cache.dart';
|
||||
import 'package:photos/repositories/file_repository.dart';
|
||||
import 'package:photos/models/file.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:photos/core/constants.dart';
|
||||
|
|
|
@ -79,11 +79,28 @@ class _ZoomableImageState extends State<ZoomableImage>
|
|||
|
||||
void _loadNetworkImage() {
|
||||
if (!_loadedSmallThumbnail && !_loadedFinalImage) {
|
||||
_imageProvider = CachedNetworkImageProvider(
|
||||
_photo.getThumbnailUrl(),
|
||||
cacheManager: ThumbnailCacheManager(),
|
||||
);
|
||||
_loadedSmallThumbnail = true;
|
||||
final cachedThumbnail = ThumbnailFileLruCache.get(_photo);
|
||||
if (cachedThumbnail != null) {
|
||||
_imageProvider = Image.file(cachedThumbnail).image;
|
||||
_loadedSmallThumbnail = true;
|
||||
} else {
|
||||
getThumbnailFromServer(_photo).then((file) {
|
||||
final imageProvider = Image.file(file).image;
|
||||
if (mounted) {
|
||||
precacheImage(imageProvider, context).then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_imageProvider = imageProvider;
|
||||
_loadedSmallThumbnail = true;
|
||||
});
|
||||
}
|
||||
}).catchError((e) {
|
||||
_logger.severe("Could not load image " + _photo.toString());
|
||||
_loadedSmallThumbnail = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!_loadedFinalImage) {
|
||||
getFileFromServer(_photo).then((file) {
|
||||
|
|
Loading…
Add table
Reference in a new issue