com.bumptech.glide.load.model.GlideUrl Java Examples
The following examples show how to use
com.bumptech.glide.load.model.GlideUrl.
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: GlideModelConfig.java From ImageLoader with Apache License 2.0 | 6 votes |
@Override public void registerComponents(Context context, Glide glide) { /** * 不带拦截功能,只是单纯替换通讯组件 */ OkHttpClient.Builder builder = new OkHttpClient.Builder(); setIgnoreAll(builder); OkHttpClient client=builder .addNetworkInterceptor(new ProgressInterceptor()) .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) .build(); glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client)); Log.i("glide","registerComponents---"); }
Example #2
Source File: SignalGlideModule.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret(); byte[] secret = attachmentSecret.getModernKey(); registry.prepend(File.class, File.class, UnitModelLoader.Factory.getInstance()); registry.prepend(InputStream.class, new EncryptedCacheEncoder(secret, glide.getArrayPool())); registry.prepend(File.class, Bitmap.class, new EncryptedBitmapCacheDecoder(secret, new StreamBitmapDecoder(new Downsampler(registry.getImageHeaderParsers(), context.getResources().getDisplayMetrics(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool()))); registry.prepend(File.class, GifDrawable.class, new EncryptedGifCacheDecoder(secret, new StreamGifDecoder(registry.getImageHeaderParsers(), new ByteBufferGifDecoder(context, registry.getImageHeaderParsers(), glide.getBitmapPool(), glide.getArrayPool()), glide.getArrayPool()))); registry.prepend(BlurHash.class, Bitmap.class, new BlurHashResourceDecoder()); registry.prepend(Bitmap.class, new EncryptedBitmapResourceEncoder(secret)); registry.prepend(GifDrawable.class, new EncryptedGifDrawableResourceEncoder(secret)); registry.append(ContactPhoto.class, InputStream.class, new ContactPhotoLoader.Factory(context)); registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context)); registry.append(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory()); registry.append(ChunkedImageUrl.class, InputStream.class, new ChunkedImageUrlLoader.Factory()); registry.append(StickerRemoteUri.class, InputStream.class, new StickerRemoteUriLoader.Factory()); registry.append(BlurHash.class, BlurHash.class, new BlurHashModelLoader.Factory()); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory()); }
Example #3
Source File: GlideUtil.java From Pixiv-Shaft with MIT License | 6 votes |
public static GlideUrl getHead(UserBean userBean) { if (userBean == null) { Common.showLog("getHead userBean == null"); return null; } if (userBean.getProfile_image_urls() == null) { Common.showLog("getHead userBean.getProfile_image_urls == null"); return null; } if (!TextUtils.isEmpty(userBean.getProfile_image_urls().getMaxImage())) { Common.showLog("getHead userBean.getProfile_image_urls.getMaxImage " + userBean.getProfile_image_urls().getMaxImage()); return new GlideUrl(userBean.getProfile_image_urls().getMaxImage(), sHeaders); } return null; }
Example #4
Source File: ArtistImageFetcher.java From Orin with GNU General Public License v3.0 | 6 votes |
@Override public InputStream loadData(Priority priority) throws Exception { if (!MusicUtil.isArtistNameUnknown(model.artistName) && Util.isAllowedToDownloadMetadata(context)) { Response<LastFmArtist> response = lastFMRestClient.getApiService().getArtistInfo(model.artistName, null, model.skipOkHttpCache ? "no-cache" : null).execute(); if (!response.isSuccessful()) { throw new IOException("Request failed with code: " + response.code()); } LastFmArtist lastFmArtist = response.body(); if (isCancelled) return null; GlideUrl url = new GlideUrl(LastFMUtil.getLargestArtistImageUrl(lastFmArtist.getArtist().getImage())); urlFetcher = urlLoader.getResourceFetcher(url, width, height); return urlFetcher.loadData(priority); } return null; }
Example #5
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 #6
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 #7
Source File: ArtistImageFetcher.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override public InputStream loadData(Priority priority) throws Exception { if (!MusicUtil.isArtistNameUnknown(model.artistName) && Util.isAllowedToDownloadMetadata(context)) { Response<LastFmArtist> response = lastFMRestClient.getApiService().getArtistInfo(model.artistName, null, model.skipOkHttpCache ? "no-cache" : null).execute(); if (!response.isSuccessful()) { throw new IOException("Request failed with code: " + response.code()); } LastFmArtist lastFmArtist = response.body(); if (isCancelled) return null; GlideUrl url = new GlideUrl(LastFMUtil.getLargestArtistImageUrl(lastFmArtist.getArtist().getImage())); urlFetcher = urlLoader.getResourceFetcher(url, width, height); return urlFetcher.loadData(priority); } return null; }
Example #8
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 #9
Source File: ArtistImageFetcher.java From Orin with GNU General Public License v3.0 | 5 votes |
public ArtistImageFetcher(Context context, LastFMRestClient lastFMRestClient, ArtistImage model, ModelLoader<GlideUrl, InputStream> urlLoader, int width, int height) { this.context = context; this.lastFMRestClient = lastFMRestClient; this.model = model; this.urlLoader = urlLoader; this.width = width; this.height = height; }
Example #10
Source File: SignalGlideModule.java From bcm-android with GNU General Public License v3.0 | 5 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { registry.append(ContactPhoto.class, InputStream.class, new ContactPhotoLoader.Factory(context)); registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context)); registry.append(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory()); registry.replace(GlideUrl.class, InputStream.class, FileHttp.INSTANCE.getOkHttpFactory()); }
Example #11
Source File: ArtistImageFetcher.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
public ArtistImageFetcher(Context context, LastFMRestClient lastFMRestClient, ArtistImage model, ModelLoader<GlideUrl, InputStream> urlLoader, int width, int height) { this.context = context; this.lastFMRestClient = lastFMRestClient; this.model = model; this.urlLoader = urlLoader; this.width = width; this.height = height; }
Example #12
Source File: GlideUtil.java From Pixiv-Shaft with MIT License | 5 votes |
public static GlideUrl getLargeImage(IllustsBean illustsBean, int i) { if (illustsBean.getPage_count() == 1) { return getLargeImage(illustsBean); } else { return new GlideUrl(illustsBean.getMeta_pages().get(i).getImage_urls().getLarge(), sHeaders); } }
Example #13
Source File: GlideUtil.java From Pixiv-Shaft with MIT License | 5 votes |
public static GlideUrl getOriginal(IllustsBean illustsBean, int i) { if (illustsBean.getPage_count() == 1) { return new GlideUrl(illustsBean.getMeta_single_page().getOriginal_image_url(), sHeaders); } else { return new GlideUrl(illustsBean.getMeta_pages().get(i).getImage_urls().getOriginal(), sHeaders); } }
Example #14
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 #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: OkHttpProgressGlideModule.java From imsdk-android with MIT License | 5 votes |
@Override public void registerComponents(Context context, Glide glide) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); builder.hostnameVerifier(SSLSocketClient.getHostnameVerifier()) .sslSocketFactory(SSLSocketClient.getSSLSocketFactory()) .connectTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) .networkInterceptors() .add(createInterceptor(new DispatchingProgressListener())); glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build())); }
Example #17
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 #18
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 #19
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 #20
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 #21
Source File: AbstractGlideModule.java From Common with Apache License 2.0 | 5 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { OkHttpClient.Builder builder = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) .readTimeout(10, TimeUnit.SECONDS) .writeTimeout(10, TimeUnit.SECONDS); SSLSocketFactory sslSocketFactory = getSSLSocketFactory(); if (sslSocketFactory != null) { builder.sslSocketFactory(sslSocketFactory); } registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build())); }
Example #22
Source File: HomeAssistAppGlideModule.java From homeassist with Apache License 2.0 | 5 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { OkHttpClient client = ServiceProvider.getGlideOkHttpClientInstance(); OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client); glide.getRegistry().replace(GlideUrl.class, InputStream.class, factory); }
Example #23
Source File: MyGlideModule.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
@Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { super.registerComponents(context, glide, registry); registry.append(AudioFileCover.class,InputStream.class,new AudioFileCoverLoader.Factory()); registry.append(ArtistImage.class,InputStream.class, new ArtistImageLoader.Factory(context)); registry.register(Bitmap.class, BitmapPaletteWrapper.class, new BitmapPaletteTranscoder()); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory()); }
Example #24
Source File: ArtistImageFetcher.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
public ArtistImageFetcher(LastFMRestClient lastFMRestClient, ArtistImage model, ModelLoader<GlideUrl, InputStream> urlLoader, int width, int height, Options options) { this.lastFMRestClient = lastFMRestClient; this.model = model; this.urlLoader = urlLoader; this.width = width; this.height = height; mOption = options; mLoadOriginal = model.mLoadOriginal; mImageNumber = model.mImageNumber; }
Example #25
Source File: BaseNet.java From AFBaseLibrary with Apache License 2.0 | 5 votes |
protected void makeGlideSupportHttps() { if (!isHttpsRequest()) { return; } Glide.get(getApplicationContext()).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(httpClient)); }
Example #26
Source File: AbstractGlideModule.java From DMusic with Apache License 2.0 | 5 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { OkHttpClient.Builder builder = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) .readTimeout(10, TimeUnit.SECONDS) .writeTimeout(10, TimeUnit.SECONDS); SSLSocketFactory sslSocketFactory = getSSLSocketFactory(); if (sslSocketFactory != null) { builder.sslSocketFactory(sslSocketFactory); } registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build())); }
Example #27
Source File: TyGlide.java From tysq-android with GNU General Public License v3.0 | 5 votes |
@Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(OkHttpHelper.getOkHttpInstance()); registry.replace(GlideUrl.class, InputStream.class, factory); }
Example #28
Source File: OkHttpUrlLoader.java From NewFastFrame with Apache License 2.0 | 4 votes |
@NonNull @Override public ModelLoader<GlideUrl, InputStream> build(@NonNull MultiModelLoaderFactory multiFactory) { return new OkHttpUrlLoader(client); }
Example #29
Source File: OkHttpUrlLoader.java From NewFastFrame with Apache License 2.0 | 4 votes |
@Nullable @Override public LoadData<InputStream> buildLoadData(@NonNull GlideUrl glideUrl, int width, int height, @NonNull Options options) { return new LoadData<>(glideUrl, new OkHttpStreamFetcher(client, glideUrl)); }
Example #30
Source File: OkHttpUrlLoader.java From NewFastFrame with Apache License 2.0 | 4 votes |
@Override public boolean handles(@NonNull GlideUrl glideUrl) { return false; }