赞
踩
http://url.com/image.jpg?token=d9caa6e02c990b0ahttp://url.com/image.jpg?token=d9caa6e02c990b0a
public class MyGlideUrl extends GlideUrl {
private String mUrl;
public MyGlideUrl(String url) {
super(url);
mUrl = url;
}
@Override
public String getCacheKey() {
return mUrl.replace(findTokenParam(), "");
}
private String findTokenParam() {
String tokenParam = "";
int tokenKeyIndex = mUrl.indexOf("?token=") >= 0 ? mUrl.indexOf("?token=") : mUrl.indexOf("&token=");
if (tokenKeyIndex != -1) {
int nextAndIndex = mUrl.indexOf("&", tokenKeyIndex + 1);
if (nextAndIndex != -1) {
tokenParam = mUrl.substring(tokenKeyIndex + 1, nextAndIndex + 1);
} else {
tokenParam = mUrl.substring(tokenKeyIndex);
}
}
return tokenParam;
}
}
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Glide.with(this)
.load(new MyGlideUrl(url))
.into(imageView);Glide.with(this) .load(new MyGlideUrl(url)) .into(imageView);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。