/** * Get the default Fresco configuration builder. * Allows adding of configuration options in addition to the default values. * * @return {@link ImagePipelineConfig.Builder} that has been initialized with default values */ public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) { HashSet<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new SystraceRequestListener()); OkHttpClient client = OkHttpClientProvider.createClient(); // make sure to forward cookies for any requests via the okHttpClient // so that image requests to endpoints that use cookies still work CookieJarContainer container = (CookieJarContainer) client.cookieJar(); ForwardingCookieHandler handler = new ForwardingCookieHandler(context); container.setCookieJar(new JavaNetCookieJar(handler)); return OkHttpImagePipelineConfigFactory .newBuilder(context.getApplicationContext(), client) .setNetworkFetcher(new ReactOkHttpNetworkFetcher(client)) .setDownsampleEnabled(false) .setRequestListeners(requestListeners); }
private static ImagePipelineConfig getDefaultConfig( Context context, @Nullable RequestListener listener, @Nullable DiskCacheConfig diskCacheConfig) { HashSet<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new SystraceRequestListener()); if (listener != null) { requestListeners.add(listener); } OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient(); ImagePipelineConfig.Builder builder = OkHttpImagePipelineConfigFactory.newBuilder(context.getApplicationContext(), okHttpClient); builder .setDownsampleEnabled(false) .setRequestListeners(requestListeners); if (diskCacheConfig != null) { builder.setMainDiskCacheConfig(diskCacheConfig); } return builder.build(); }
private byte[] loadFromUrl(String url) { try { Request request = new Request.Builder().url(url).get().build(); Response response = OkHttpClientProvider.createClient().newCall(request).execute(); return response.body().bytes(); } catch (IOException e) { throw new IllegalStateException("Could not fetch data from url " + url); } }
public RNPacketzoomModule(ReactApplicationContext reactContext) { super(reactContext); this.reactContext = reactContext; OkHttpClient client = OkHttpClientProvider.getOkHttpClient(); OkHttpClient replacementClient = client .newBuilder() .addInterceptor(new PacketZoomInterceptor()) .build(); OkHttpClientProvider.replaceOkHttpClient(replacementClient); }
private static ImagePipelineConfig getDefaultConfig(Context context) { HashSet<RequestListener> requestListeners = new HashSet<>(); requestListeners.add(new SystraceRequestListener()); return OkHttpImagePipelineConfigFactory .newBuilder(context.getApplicationContext(), OkHttpClientProvider.getOkHttpClient()) .setDownsampleEnabled(false) .setRequestListeners(requestListeners) .build(); }
private static HttpDataSource.Factory buildHttpDataSourceFactory(Context context, DefaultBandwidthMeter bandwidthMeter) { return new OkHttpDataSourceFactory(OkHttpClientProvider.getOkHttpClient(), getUserAgent(context), bandwidthMeter); }