Preload remote thumbnails too
This commit is contained in:
parent
8aae51c055
commit
c24a94181b
|
@ -319,7 +319,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
|
|||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index < widget.memories.length - 1) {
|
||||
final nextFile = widget.memories[index + 1].file;
|
||||
preloadLocalFileThumbnail(nextFile);
|
||||
preloadThumbnail(nextFile);
|
||||
}
|
||||
final file = widget.memories[index].file;
|
||||
return MemoryItem(file);
|
||||
|
|
|
@ -128,22 +128,25 @@ void preloadFile(File file) {
|
|||
}
|
||||
}
|
||||
|
||||
void preloadLocalFileThumbnail(File file) {
|
||||
if (file.localID == null ||
|
||||
ThumbnailLruCache.get(file, THUMBNAIL_SMALL_SIZE) != null) {
|
||||
return;
|
||||
}
|
||||
file.getAsset().then((asset) {
|
||||
asset
|
||||
.thumbDataWithSize(
|
||||
THUMBNAIL_SMALL_SIZE,
|
||||
THUMBNAIL_SMALL_SIZE,
|
||||
quality: THUMBNAIL_QUALITY,
|
||||
)
|
||||
.then((data) {
|
||||
ThumbnailLruCache.put(file, THUMBNAIL_SMALL_SIZE, data);
|
||||
void preloadThumbnail(File file) {
|
||||
if (file.localID == null) {
|
||||
getThumbnailFromServer(file);
|
||||
} else {
|
||||
if (ThumbnailLruCache.get(file, THUMBNAIL_SMALL_SIZE) != null) {
|
||||
return;
|
||||
}
|
||||
file.getAsset().then((asset) {
|
||||
asset
|
||||
.thumbDataWithSize(
|
||||
THUMBNAIL_SMALL_SIZE,
|
||||
THUMBNAIL_SMALL_SIZE,
|
||||
quality: THUMBNAIL_QUALITY,
|
||||
)
|
||||
.then((data) {
|
||||
ThumbnailLruCache.put(file, THUMBNAIL_SMALL_SIZE, data);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<io.File> getNativeFile(File file) async {
|
||||
|
|
Loading…
Reference in a new issue