我可以改变通用图像加载SD卡缓存键紧急??缓存、图像、加载、紧急

2023-09-07 03:16:57 作者:不管你多糟但我都爱

由于我的形象乌里采用不同的方式,以确保应用程序pivture是安全的。当我要求它改变每次。例如,它可以是像这个

As my image Uri uses a different way to make sure the App pivture is safe. It changes everytime when I request. For example, it may be like this

和下一次谈到像这个

由于通用图像加载器使​​用URI作为SD Chche键。图像乌里变动URI的结束我希望只使用这一部分关键结果我搜索了很久,但仍然不`吨得到答案。所以,请帮助我

As universal image loader uses the Uri as key for SD Chche . The image Uri changes for the end of the Uri I want to use only this part as key I searched for a long time but still don`t get the answer. So please help me

推荐答案

此问题是pretty简单的改变。诺斯特拉的通用图像加载器使​​用接口 FileNameGenerator 的方法,在com.nostra13.universalimageloader.cache.disc.naming生成;只要创建或修改一个类有,并使用这个你的目的。例如。变化哈希codeFileNameGenerator为:

This issue is pretty simple to change. Nostra's universal image loader uses a interface "FileNameGenerator" with the method "generate" in com.nostra13.universalimageloader.cache.disc.naming; Just create or adapt a class there and use this for your purpose. E.g. change HashCodeFileNameGenerator to:

 public class HashCodeFileNameGenerator implements FileNameGenerator {
@Override
public String generate(String imageUri) {
    return String.valueOf(imageUri.substr(0, imageUri.indexOf("=")).hashCode());
}
 }

在code以上将基于图像的URL,直到符号=的第一次出现生成一个文件名。

The code above would generate a filename based on the image url till the first occurence of the sign '='.