我正在使用Glide版本= 4.7.1
我不知道如何通过滑行认证图像。 这段代码是我做的。
我创建了:
private static final String AUTHORIZATION = "ss-id=doa3cx8OV3aGLThRrpnh;";
private static final String ABC = "application/json";
public static GlideUrl getUrlWithHeaders(String url){
return new GlideUrl(url, new LazyHeaders.Builder()
.addHeader("Cookie", AUTHORIZATION)
.addHeader("Accept", ABC)
.build());
}
}
String s = "http://192.168.1.144/api/download/" + mImageIds.get(position);
GlideApp
.with(mContext)
.load(Headers.getUrlWithHeaders(s))
.centerCrop()
.transition(DrawableTransitionOptions.withCrossFade())
.into((imageView));
任何帮助,
答案 0 :(得分:4)
这是我的Glide v3的工作代码,但我想它与v4兼容:
String url = "http://192.168.1.144/api/download/" + mImageIds.get(position);
GlideUrl glideUrl = new GlideUrl(url,
new LazyHeaders.Builder()
.addHeader("Cookie", AUTHORIZATION)
.addHeader("Accept", ABC)
.build());
Glide.with(this)
.load(glideUrl)
.into(imageView);
答案 1 :(得分:1)
科特林
val url:String="https://URL.com/" + data[position].image_path;
val glideUrl = GlideUrl(
url,
LazyHeaders.Builder()
.addHeader("Authorization", "Bearer $token")
.build()
)
Glide.with(mContext)
.load(glideUrl)
.into(holder.binding.img);