壁画中的Android图像无效 [英] Android Image invalidate in fresco

查看:95
本文介绍了壁画中的Android图像无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Android图像缓存库从毕加索迁移到壁画.我想知道是否有任何方法可以使已经捕获的图像无效,因为我正在添加功能来替换现有图像,因此有办法在像毕加索这样的

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

此行删除缓存的图像,并使用所提供的url使用新的图像,

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

http://example.com/image_path

在壁画中,我尝试使用

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.

推荐答案

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.

这篇关于壁画中的Android图像无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆