凌空NetworkImageView清晰缓存图像 [英] Volley NetworkImageView clear cached image

查看:135
本文介绍了凌空NetworkImageView清晰缓存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道是否有可能清除缓存图像使用谷歌乱射库中的一NetworkImageView?

Does anybody know if it is possible to clear the cached image from a single NetworkImageView using Googles Volley library?

我有一个NetworkImageView化身图像,并想展示新形象,一旦我已经上传到服务器。在如果我做的那一刻   profileImg.setImageUrl(myUrl,mImageLoader); 我得到的缓存图片

I have an avatar image in a NetworkImageView and would like to show the new image once I have uploaded it to the server. At the moment if I do profileImg.setImageUrl("myUrl", mImageLoader); I get the cached image.

推荐答案

所以要迟回答我的问题。最后我采取了不同的方法,以确保我总是化身图像的最新版本,它被证明是非常简单的。

So to belatedly answer my own question. I ended up taking a different approach to ensure that I always get the latest copy of an avatar image and it turned out to be very simple.

而不是试图清除从我用下面的方法缓存单独的图像。

Instead of trying to clear out an individual image from the cache I use the following method.

int time = (int) (System.currentTimeMillis());//gets the current time in milliseconds
String myUrl = "www.mySite.com?timestamp=" + String.ValueOf(time);
profileImg.setImageUrl("myUrl", mImageLoader);

这样做是为追加一个虚参数的URL我打电话来获得图像与当前时间戳。这保证了我一直在打电话给唯一的URL等于是我总是得到最先进的最新版本的图像。

What this does is to append an imaginary parameter to the url I call to get the image with a current timestamp. This guarantees that I am always making a call to a unique url and so therefore am always getting the most up-to-date version of that image.

这种方法的优点在于它并不局限于凌空然而,可以使用你选择做网络调用。

The beauty of this approach is that it is not limited to Volley and can be used however you choose to make network calls.

这篇关于凌空NetworkImageView清晰缓存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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