In my app I was prefetching images so they load faster when user scrolls using prefetchToBitmapCache
. Now when user applies a filter, these prefetches remain in pipeline and slow down the loading of new images.
How I am prefetching: When use scrolls down through images, I prefetch X number of images after LinearLayoutManager.findLastVisibleItemPosition()
's value. I need a way to cancel all these prefetches when user applies a filter. Is there a way to do this or a better way of prefetching?
I am part of the Fresco team and may be able to help.
Both imagePipeline.prefetchToDiskCache
and imagePipeline.prefetchToBitmapCache
return DataSource<Void>
object. If you store the returned instance somewhere, you can just close it and that should cancel the prefetch.
// initiate prefetch
prefetchDataSource = imagePipeline.prefetchToBitmapCache(imageRequest, callerContext);
// cancel prefetch
prefetchDataSource.close();