我可以改变通用图像加载SD卡缓存键紧急?? [英] Can I change the universal image loader SDcard cache key??Emergency
问题描述
由于我的形象乌里采用不同的方式,以确保应用程序pivture是安全的。
当我要求它改变每次。例如,它可以是像<一个href=\"http://youyou.qiniudn.com/ff6158ca2330b0?e=1376038933&token=2xD9fSrurwz0o0YpXNXUmRwpwnXcXYZsr4MnLd7f:i3-XdQtwFWIVn1c-0r5xgIhQuvE=\"相对=nofollow>这个
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
和下一次谈到像<一个href=\"http://youyou.qiniudn.com/ff6158ca2330b0e=1376038933&token=2xD9fSrurwz0o0YpXNXUmRwpwnXcXYZsr4MnLd7f:ZHKI4KfDL_snisR_UxZcACz8ICE=\"相对=nofollow>这个
由于通用图像加载器使用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简单的改变。诺斯特拉的通用图像加载器使用接口<一个href=\"https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/library/src/com/nostra13/universalimageloader/cache/disc/naming/FileNameGenerator.java\"相对=nofollow> 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 '='.
这篇关于我可以改变通用图像加载SD卡缓存键紧急??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!