com.bumptech.glide.load.model.LazyHeaders Java Examples
The following examples show how to use
com.bumptech.glide.load.model.LazyHeaders.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageFragment.java From MoeGallery with GNU General Public License v3.0 | 6 votes |
private void cacheImage(final Image image, final LazyHeaders.Builder header) { mName = image.getName(); mUri = image.getFileUrl(); saveImage(image); mRequestManager.load(new GlideUrl(image.getFileUrl(), header.build())) .downloadOnly(new SimpleTarget<File>() { @Override public void onResourceReady(File resource, GlideAnimation<? super File> glideAnimation) { if (mSetting.autoDownload()) { File dir = new File( Environment.getExternalStorageDirectory().getPath(), "MoeGallery"); String fileName = image.getName().replace('/', '-'); Utils.copy(resource, dir, fileName); mImageDataSource.cacheImageUri(mImage.getFileUrl(), Uri.fromFile(new File(dir, fileName))); } loadImage(image, header); } }); mImageDataSource.cacheDetail(mImage.getFileUrl(), image); }
Example #2
Source File: HuaBanAdapter.java From v9porn with MIT License | 6 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { String host = null; String referer = null; try { URL urlObj = new URL(url); host = urlObj.getHost(); referer = urlObj.getProtocol() + "://" + urlObj.getHost() + "/"; } catch (MalformedURLException e) { e.printStackTrace(); } LazyHeaders.Builder builder = new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("Host", "i.meizitu.net") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"); if (referer != null) { builder.addHeader("Referer", referer); builder.addHeader("Host", host); } return new GlideUrl(url, builder.build()); } }
Example #3
Source File: MeiZiTuAdapter.java From v9porn with MIT License | 6 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { String host = null; String referer = null; try { URL urlObj = new URL(url); host = urlObj.getHost(); referer = urlObj.getProtocol() + "://" + urlObj.getHost() + "/"; } catch (MalformedURLException e) { e.printStackTrace(); } LazyHeaders.Builder builder = new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"); if (referer != null) { builder.addHeader("Referer", referer); builder.addHeader("Host", host); } return new GlideUrl(url, builder.build()); } }
Example #4
Source File: TyUtils.java From tysq-android with GNU General Public License v3.0 | 6 votes |
private static void getGlideRequest(Context context, String url, RequestOptions options, ImageView imageView) { RequestBuilder<Drawable> requestBuilder; List<Cookie> cookies = PersistentCookieStore.getInstance().getCookies(); if (TextUtils.isEmpty(url)) { requestBuilder = Glide.with(context).load(url); } else if (cookies == null || cookies.size() <= 0) { requestBuilder = Glide.with(context).load(url); } else { LazyHeaders.Builder builder = new LazyHeaders.Builder(); for (int i = 0; i < cookies.size(); i++) { Cookie cookie = cookies.get(i); String value = cookie.name() + "=" + cookie.value(); builder.setHeader("Cookie", value); } GlideUrl glideUrl = new GlideUrl(url, builder.build()); requestBuilder = Glide.with(context).load(glideUrl); } if (options != null) { requestBuilder.apply(options); } requestBuilder.into(imageView); }
Example #5
Source File: PictureAdapter.java From v9porn with MIT License | 6 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { return new GlideUrl(url, new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") // .addHeader("Host", "i.meizitu.net") .addHeader("Referer", "https://www.mzitu.com/204607") .addHeader(":authority", "i5.mmzztt.com") .addHeader(":path", "/2019/09/25b01.jpg") .addHeader(":method", "GET") .addHeader(":scheme", "https") .addHeader("accept", "image/webp,image/apng,image/*,*/*;q=0.8") .addHeader("accept-encoding", "gzip, deflate, br") .addHeader("cache-control", "no-cache") .addHeader("pragma", "no-cache") .addHeader("sec-fetch-mode", "no-cors") .addHeader("sec-fetch-site", "cross-site") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36") .build()); } }
Example #6
Source File: PictureAdapter.java From v9porn with MIT License | 5 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { String referer = null; String host = null; try { URL urlObj = new URL(url); host = urlObj.getHost(); referer = urlObj.getProtocol() + "://" + urlObj.getHost() + "/"; } catch (MalformedURLException e) { e.printStackTrace(); } LazyHeaders.Builder builder = new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"); if (referer != null) { builder.addHeader("Referer", referer); builder.addHeader("Host", host); } return new GlideUrl(url, builder.build()); } }
Example #7
Source File: ImageFragment.java From MoeGallery with GNU General Public License v3.0 | 5 votes |
private void loadImage(Image image, LazyHeaders.Builder header) { if (mUri != null && mUri.toLowerCase().endsWith("gif")) { mGifRequestBuilder.load(new GlideUrl(image.getFileUrl(), header.build())) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .listener(new MediaRequestListener<GlideUrl, GifDrawable>()) .into(mPhotoView); } else { mRequestManager.load(new GlideUrl(image.getFileUrl(), header.build())) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .listener(new MediaRequestListener<GlideUrl, GlideDrawable>()) .into(mPhotoView); } }
Example #8
Source File: SingleSignOnUrl.java From nextcloud-notes with GNU General Public License v3.0 | 5 votes |
/** * 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(); }
Example #9
Source File: GirlsAdapter.java From FakeWeather with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(final GirlViewHolder holder, final int position) { final Girl girl = girls.get(position); if (girl.getHeight() != 0) { holder.iv.setOriginalSize(girl.getWidth(), girl.getHeight()); } else { holder.iv.setOriginalSize(236, 354); } holder.iv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TextUtils.isEmpty(girl.getLink())) { startPictureActivity(view, position); } else { Intent intent = MzituPictureActivity.newIntent(context, girl.getLink(), ""); context.startActivity(intent); } } }); if (TextUtils.isEmpty(girl.getRefer())) { Glide.with(context).load(girl.getUrl()).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.ic_glide_holder).crossFade(500).into(holder.iv); } else { GlideUrl glideUrl = new GlideUrl(girl.getUrl(), new LazyHeaders.Builder() .addHeader("Referer", girl.getRefer()) .build()); Glide.with(context).load(glideUrl).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.ic_glide_holder).crossFade(500).into(holder.iv); } }
Example #10
Source File: GlideUtil.java From browser with GNU General Public License v2.0 | 5 votes |
public static void displayImageReferer(String url,ImageView imageView,String referer) { if(url==null){ return; } LazyHeaders.Builder builder=new LazyHeaders.Builder().addHeader("User-Agent", UserAgent); if(referer!=null){ builder.addHeader("Referer", referer); } /* .addHeader("key2", new LazyHeaderFactory() { @Override public String buildHeader() { String expensiveAuthHeader = computeExpensiveAuthHeader(); return expensiveAuthHeader; } }) */ GlideUrl glideUrl = new GlideUrl(url,builder.build()); Glide.with(MainApp.getContext()) .load(glideUrl) .placeholder(R.drawable.pictures_no) .thumbnail(0.2f) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .into(imageView); }
Example #11
Source File: MeiZiTuAdapter.java From v9porn with MIT License | 5 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { return new GlideUrl(url, new LazyHeaders.Builder() //.addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") //.addHeader("Host", "i.meizitu.net") .addHeader("Referer", "https://www.mzitu.com/") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36") .build()); } }
Example #12
Source File: HuaBanAdapter.java From v9porn with MIT License | 5 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { return new GlideUrl(url, new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("Host", "i.meizitu.net") .addHeader("Referer", "http://www.mzitu.com/") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36") .build()); } }
Example #13
Source File: PictureAdapter.java From v9porn with MIT License | 5 votes |
private GlideUrl buildGlide99MMUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { HttpUrl httpUrl = HttpUrl.parse(url); return new GlideUrl(url, new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("Host", httpUrl != null ? httpUrl.host() : "img.99mm.net") .addHeader("Referer", "http://www.99mm.me/") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36") .build()); } }
Example #14
Source File: Mm99Adapter.java From v9porn with MIT License | 5 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { HttpUrl httpUrl=HttpUrl.parse(url); return new GlideUrl(url, new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("Host", (httpUrl != null ? httpUrl.host() : "img.99mm.net")) .addHeader("Referer", "http://www.99mm.me/") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36") .build()); } }
Example #15
Source File: PictureAdapter.java From v9porn with MIT License | 5 votes |
@Deprecated private GlideUrl buildGlide99MMUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { HttpUrl httpUrl = HttpUrl.parse(url); return new GlideUrl(url, new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("Host", httpUrl != null ? httpUrl.host() : "img.99mm.net") .addHeader("Referer", "http://www.99mm.me/") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36") .build()); } }
Example #16
Source File: Mm99Adapter.java From v9porn with MIT License | 5 votes |
private GlideUrl buildGlideUrl(String url) { if (TextUtils.isEmpty(url)) { return null; } else { HttpUrl httpUrl=HttpUrl.parse(url); return new GlideUrl(url, new LazyHeaders.Builder() .addHeader("Accept-Language", "zh-CN,zh;q=0.9,zh-TW;q=0.8") .addHeader("Host", (httpUrl != null ? httpUrl.host() : "img.99mm.net")) .addHeader("Referer", "http://www.99mm.me/") .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36") .build()); } }
Example #17
Source File: PhotoViewWrapper.java From react-native-image-zoom with MIT License | 4 votes |
public void setSource(ReadableMap params) { mParams = params; @Nullable Uri mUri = null; String source = params.hasKey("uri") ? params.getString("uri") : null; String thumbnail = params.hasKey("thumbnail") ? params.getString("thumbnail") : null; ReadableMap headers = params.hasKey("headers") ? params.getMap("headers") : null; //handle base64 if (source.startsWith("data:image/png;base64,")){ Glide .with(this.getContext()) .load(Base64.decode(source.replaceAll("data:image\\/.*;base64,", ""), Base64.DEFAULT)) .into(this) ; return; } boolean useStorageFile = false ; // handle bundled app resources try { mUri = Uri.parse(source); // Verify scheme is set, so that relative uri (used by static resources) are not handled. if (mUri.getScheme() == null) { mUri = null; } else if( !mUri.getScheme().equals("http") && !mUri.getScheme().equals("https") ){ useStorageFile = true ; if (!mInitialized) { this.setImageURI(mUri); } } } catch (Exception e) { // ignore malformed uri, then attempt to extract resource ID. } if (mUri == null) { mUri = mResourceDrawableIdHelper.getResourceDrawableUri( this.getContext(), source ); Glide .with(this.getContext()) .load(mUri) .into(this); } else if (useStorageFile) { Glide .with(this.getContext()) .load(mUri) .into(this); } else { // Handle an http / https address RequestListener listener = this.getRequestListener(); LazyHeaders.Builder lazyHeaders = new LazyHeaders.Builder(); Log.d("null headers", String.valueOf(headers != null)); if(headers != null){ ReadableMapKeySetIterator it = headers.keySetIterator(); Log.d("next headers", String.valueOf(it.hasNextKey())); while(it.hasNextKey()){ String Key = it.nextKey(); lazyHeaders.addHeader(Key, headers.getString(Key)); } } Log.d("thing", mUri.toString()); DrawableRequestBuilder builder = Glide .with(this.getContext()) .load(new GlideUrl(mUri.toString(), lazyHeaders.build())) .listener(listener); //set thumbnails if(thumbnail != null) { DrawableRequestBuilder<String> thumbnailRequest = Glide .with(this.getContext()) .load(thumbnail); builder = builder.thumbnail(thumbnailRequest); } builder.into(this); } this.setChangeListeners(); }
Example #18
Source File: ImageFragment.java From MoeGallery with GNU General Public License v3.0 | 4 votes |
private static LazyHeaders.Builder header() { return new LazyHeaders.Builder().addHeader("User-Agent", OkHttp.USER_AGENT); }
Example #19
Source File: ContentItem.java From Hentoid with Apache License 2.0 | 4 votes |
private void attachCover(@NonNull final Content content) { String thumbLocation = content.getCover().getFileUri(); if (thumbLocation.isEmpty()) thumbLocation = content.getCover().getUrl(); if (thumbLocation.isEmpty()) thumbLocation = content.getCoverImageUrl(); // Use content's cookies to load image (useful for ExHentai when viewing queue screen) if (thumbLocation.startsWith("http") && content.getDownloadParams() != null && content.getDownloadParams().length() > 2 // Avoid empty and "{}" && content.getDownloadParams().contains(HttpHelper.HEADER_COOKIE_KEY)) { Map<String, String> downloadParams = null; try { downloadParams = JsonHelper.jsonToObject(content.getDownloadParams(), JsonHelper.MAP_STRINGS); } catch (IOException e) { Timber.w(e); } if (downloadParams != null && downloadParams.containsKey(HttpHelper.HEADER_COOKIE_KEY)) { String cookiesStr = downloadParams.get(HttpHelper.HEADER_COOKIE_KEY); if (cookiesStr != null) { LazyHeaders.Builder builder = new LazyHeaders.Builder() .addHeader(HttpHelper.HEADER_COOKIE_KEY, cookiesStr); GlideUrl glideUrl = new GlideUrl(thumbLocation, builder.build()); Glide.with(ivCover) .load(glideUrl) .apply(glideRequestOptions) .into(ivCover); return; } } } if (thumbLocation.startsWith("http")) Glide.with(ivCover) .load(thumbLocation) .apply(glideRequestOptions) .into(ivCover); else Glide.with(ivCover) .load(Uri.parse(thumbLocation)) .apply(glideRequestOptions) .into(ivCover); }
Example #20
Source File: SingleSignOnUrl.java From nextcloud-notes with GNU General Public License v3.0 | 2 votes |
/** * 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) { this.headers = new LazyHeaders.Builder().addHeader(X_HEADER_SSO_ACCOUNT_NAME, ssoAccountName).build(); }