Android毕加索清除缓存 [英] android picasso clear cache

查看:162
本文介绍了Android毕加索清除缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用毕加索显示自己的肖像,当更改肖像时,我想清除此用户的缓存(或所有用户的肖像缓存),这是我的代码,它不起作用,任何人都可以帮助我?

I am using Picasso to show one's portrait, when the protrait is changed, I want to clear this user's cache(or all users' portrait cache), here is my code, and it doesn't work,anyone can help me?

LruCache lruCache = new LruCache(context);
lruCache.clear();
Picasso picasso = new Picasso.Builder(context).memoryCache(lruCache).build();
picasso.load(portraitUrl).resize(50, 50).centerCrop().error(R.drawable.user_portrait).into(portaitView);

推荐答案

在毕加索的最新版本中,有一种新的作废方法,没有任何解决方法,因此我认为前面提到的自定义PicassoTools类现在已过时

In the recent versions of Picasso, there is a new method for invalidate, without any workarounds, so I think that custom PicassoTools class mentioned earlier, is now obsolete

Picasso.with(getActivity()).invalidate(file);

这篇关于Android毕加索清除缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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