Android Image invalidate in fresco
Asked Answered
P

2

1

I am migrating android image caching library from picasso to fresco. I want to know if there is any way to invalidate image already catched as I am adding feature to replace existing image there is way to do so in picasso like

Picasso.with(context).invalidate(URI);

This line remove the cached image and use new one using the url provided which is same like,

http://example.com/image_path

In fresco I have tried using

Fresco.getImagePipeline().evictFromMemoryCache(uri);

This is removing image from view but adding same old cached image again and not getting new one from network as it is working in picasso.


Please refer question Invalidate cache in Picasso The accepted answer doing great in case of picasso.

Pastelist answered 15/5, 2015 at 7:44 Comment(0)
P
3
Fresco.getImagePipeline().evictFromMemoryCache(uri);

Above code line remove the image from the catche but image remains there in the disk and render same if called. We need to remove same image from disk as well. Bellow two lines remove the the image from disc cache also we need to remove the small that is thumbnail image if saved from disk cache.

Fresco.getImagePipelineFactory().getMainDiskStorageCache().remove(new SimpleCacheKey(uri.toString()));
Fresco.getImagePipelineFactory().getSmallImageDiskStorageCache().remove(new SimpleCacheKey(uri.toString()));

Note: if you are using custom cache key you need to change it that way.

Pastelist answered 15/5, 2015 at 10:9 Comment(0)
D
1

Try this

public static void clearCache(){
            //
            ImagePipeline imagePipeline = com.facebook.drawee.backends.pipeline.Fresco.getImagePipeline();
            imagePipeline.clearMemoryCaches();
            imagePipeline.clearDiskCaches();
            // combines above two lines
            imagePipeline.clearCaches();
        }
Demodena answered 13/9, 2018 at 18:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.