下面列出了怎么用com.bumptech.glide.load.model.Headers的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Use this as {@link Headers} if you want to do a {@link Glide} request for an {@link SingleSignOnAccount} which is not set by {@link SingleAccountHelper} as current {@link SingleSignOnAccount}.
*
* @param ssoAccountName Account name from which host the request should be fired (needs to match {@link SingleSignOnAccount#name})
*/
public SingleSignOnOriginHeader(@NonNull String ssoAccountName, Headers headers) {
LazyHeaders.Builder builder = new LazyHeaders.Builder();
for (Map.Entry<String, String> entry : headers.getHeaders().entrySet()) {
builder.addHeader(entry.getKey(), entry.getValue());
}
builder.addHeader(X_HEADER_SSO_ACCOUNT_NAME, ssoAccountName).build();
this.headers = builder.build();
}
public ProgressableGlideUrl(URL url, Headers headers) {
super(url, headers);
}
public ProgressableGlideUrl(String url, Headers headers) {
super(url, headers);
}
public ProgressableGlideUrl(URL url, Headers headers) {
super(url, headers);
}
public ProgressableGlideUrl(String url, Headers headers) {
super(url, headers);
}
@Override protected Headers getHeaders(String model, int width, int height) {
return HEADERS;
}
@Override protected Headers getHeaders(String model, int width, int height, Options options) {
return HEADERS;
}
public SingleSignOnUrl(@NonNull SingleSignOnAccount ssoAccount, @NonNull String url, @NonNull Headers headers) {
this(ssoAccount.name, url, headers);
}
public SingleSignOnUrl(@NonNull SingleSignOnAccount ssoAccount, @NonNull URL url, @NonNull Headers headers) {
this(ssoAccount.name, url, headers);
}
public SingleSignOnUrl(@NonNull String ssoAccountName, @NonNull String url, @NonNull Headers headers) {
super(url, new SingleSignOnOriginHeader(ssoAccountName, headers));
}
public SingleSignOnUrl(@NonNull String ssoAccountName, @NonNull URL url, @NonNull Headers headers) {
super(url, new SingleSignOnOriginHeader(ssoAccountName, headers));
}
/**
* Get the headers for the given model and dimensions as a map of strings to sets of strings.
*
* @param model The model.
* @param width The width in pixels of the view/target the image will be loaded into.
* @param height The height in pixels of the view/target the image will be loaded into.
* @return The Headers object containing the headers, or null if no headers should be added.
*/
protected Headers getHeaders(T model, int width, int height) {
return Headers.DEFAULT;
}