Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何在不清除缓存的情况下,强制直接从网络加载图片呢 #6

Open
skindhu opened this issue Jun 1, 2016 · 1 comment

Comments

@skindhu
Copy link

skindhu commented Jun 1, 2016

请问如何在不清除缓存的情况下,强制直接从网络加载图片呢

@desmond1121
Copy link
Owner

desmond1121 commented Jun 14, 2016

@huli1987 仅某个情况用时,你可以只清除指定url的缓存:

final ImageRequest request = ImageRequest.fromUri(Uri.parse("url"));
CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(request);
StagingArea.getInstance().remove(cacheKey);
Fresco.getImagePipelineFactory().getMainDiskStorageCache().remove(cacheKey);

你一定要达到这种目的的话,可以在ImageRequest设置最低缓存层级,禁止这次的请求获取缓存内容,但是它至少会检查内存缓存。

ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse("url"))
   .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE)
   .build();

如果一定要全局这么搞,你可以在初始化的时候设置CacheKeyFactory给ImagePipelineConfig,让它每次返回不同的缓存key,就能达到你的目的了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants