Java Code Examples for com.bumptech.glide.Registry#replace()
The following examples show how to use
com.bumptech.glide.Registry#replace() .
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: 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 2
Source File: MyAppGlideModule.java From nativescript-image-cache-it with Apache License 2.0 | 6 votes |
@Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { super.registerComponents(context, glide, registry); OkHttpClient okHttpClient = new OkHttpClient(); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient)); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(createInterceptor(progressListener)) .build(); OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client); registry.replace(GlideUrl.class, InputStream.class, factory); for (ImageHeaderParser parser : registry.getImageHeaderParsers()) { if (parser instanceof ExifInterfaceImageHeaderParser) { registry.getImageHeaderParsers().remove(parser); } } }
Example 3
Source File: GlideModelConfig.java From ImageLoader with Apache License 2.0 | 6 votes |
@Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { /** * 不带拦截功能,只是单纯替换通讯组件 */ 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(); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client)); Log.i("glide","registerComponents---"); }
Example 4
Source File: GlideConfiguration.java From MVPArms with Apache License 2.0 | 5 votes |
@Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { //Glide 默认使用 HttpURLConnection 做网络请求,在这切换成 Okhttp 请求 AppComponent appComponent = ArmsUtils.obtainAppComponentFromContext(context); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(appComponent.okHttpClient())); BaseImageLoaderStrategy loadImgStrategy = appComponent.imageLoader().getLoadImgStrategy(); if (loadImgStrategy instanceof GlideAppliesOptions) { ((GlideAppliesOptions) loadImgStrategy).registerComponents(context, glide, registry); } }
Example 5
Source File: PandroidLibraryGlideModule.java From pandroid with Apache License 2.0 | 5 votes |
protected static void setupOkHttpClient(@NonNull Context context, @NonNull Registry registry) { if (!setupOkHttpClient) { setupOkHttpClient = true; OkHttpClient.Builder builder = PandroidApplication.getInjector(context).getBaseComponent().okHttpClientBuilder(); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build())); } }
Example 6
Source File: GlideConfiguration.java From MVVMArms with Apache License 2.0 | 5 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { super.registerComponents(context, glide, registry); //Glide默认使用HttpURLConnection做网络请求,在这切换成okhttp请求 registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(RepositoryUtils.INSTANCE.obtainRepositoryComponent(context).okHttpClient())); }
Example 7
Source File: GlideModule.java From glide-support with The Unlicense | 5 votes |
@Override public void registerComponents( @NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { // just to see the headers actually went through, Stetho or proxy can also be used for this registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(new OkHttpClient.Builder() .addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.HEADERS)) .build())); // override default loader with one that attaches headers registry.replace(String.class, InputStream.class, new HeaderedLoader.Factory()); }
Example 8
Source File: GlideModule.java From glide-support with The Unlicense | 5 votes |
@Override public void registerComponents( @NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { super.registerComponents(context, glide, registry); com.facebook.stetho.Stetho.initializeWithDefaults(context); okhttp3.OkHttpClient client = new okhttp3.OkHttpClient.Builder() .addNetworkInterceptor(new com.facebook.stetho.okhttp3.StethoInterceptor()) .build(); registry.replace(GlideUrl.class, InputStream.class, new com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader.Factory(client)); }
Example 9
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 10
Source File: CustomGlideModule.java From Android-App-Architecture-MVVM-Databinding with Apache License 2.0 | 5 votes |
@Override public void registerComponents(final Context context, final Glide glide, final Registry registry) { final OkHttpClient.Builder builder = new OkHttpClient().newBuilder(); builder.connectTimeout(15, TimeUnit.SECONDS); builder.readTimeout(30, TimeUnit.SECONDS); // Uncomment to use Stetho network debugging // if (BuildConfig.DEBUG) { // builder.addNetworkInterceptor(new com.facebook.stetho.okhttp3.StethoInterceptor()).build(); // } final OkHttpClient client = builder.build(); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client)); }
Example 11
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 12
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 13
Source File: GlideConfiguration.java From ProgressManager with Apache License 2.0 | 4 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { BaseApplication application = (BaseApplication) context.getApplicationContext(); //Glide 底层默认使用 HttpConnection 进行网络请求,这里替换为 Okhttp 后才能使用本框架,进行 Glide 的加载进度监听 registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(application.getOkHttpClient())); }
Example 14
Source File: OKHttpLibraryGlideModule.java From Protein with Apache License 2.0 | 4 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory()); }
Example 15
Source File: SingleSignOnLibraryGlideModule.java From nextcloud-notes with GNU General Public License v3.0 | 4 votes |
@Override public void registerComponents( @NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { Log.v(TAG, "Replacing default implementation for " + GlideUrl.class.getSimpleName() + "."); registry.replace(GlideUrl.class, InputStream.class, new SingleSignOnUrlLoader.Factory(context)); }
Example 16
Source File: GlideConfiguration.java From Aurora with Apache License 2.0 | 4 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { //Glide 默认使用 HttpURLConnection 做网络请求,在这切换成 Okhttp 请求 AppComponent appComponent = ArmsUtils.obtainAppComponentFromContext(context); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(appComponent.okHttpClient())); }
Example 17
Source File: BaseGlide.java From BaseProject with Apache License 2.0 | 4 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { super.registerComponents(context, glide, registry); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(ProgressManager.getOkHttpClient())); }
Example 18
Source File: GlideConfiguration.java From AcgClub with MIT License | 4 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { //Glide默认使用HttpURLConnection做网络请求,在这切换成okhttp请求 registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(Utils.getAppComponent().okHttpClient())); }
Example 19
Source File: GlobalOkHttpGlideModule.java From glide-support with The Unlicense | 4 votes |
@Override public void registerComponents(Context context, Glide glide, Registry registry) { okhttp3.OkHttpClient client = new OkHttpClient.Builder().build(); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client)); }
Example 20
Source File: GlideConfig.java From NewFastFrame with Apache License 2.0 | 3 votes |
@Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(BaseApplication.getAppComponent().getOkHttpClient()); registry.replace(GlideUrl.class, InputStream.class, factory); }