Preload remote thumbnails too

This commit is contained in:
Vishnu Mohandas 2021-04-27 21:59:58 +05:30
parent 8aae51c055
commit c24a94181b
2 changed files with 19 additions and 16 deletions

View file

@ -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);

View 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 {