diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java index d77f06dc6..8d467275d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java @@ -15,6 +15,7 @@ import android.content.Context; import android.support.annotation.Nullable; import com.facebook.cache.common.CacheKey; +import com.facebook.cache.disk.DiskCacheConfig; import com.facebook.common.internal.AndroidPredicates; import com.facebook.common.soloader.SoLoaderShim; import com.facebook.drawee.backends.pipeline.Fresco; @@ -39,6 +40,7 @@ public class FrescoModule extends ReactContextBaseJavaModule implements ModuleDataCleaner.Cleanable { @Nullable RequestListener mRequestListener; + @Nullable DiskCacheConfig mDiskCacheConfig; public FrescoModule(ReactApplicationContext reactContext) { super(reactContext); @@ -49,6 +51,15 @@ public class FrescoModule extends ReactContextBaseJavaModule implements mRequestListener = listener; } + public FrescoModule( + ReactApplicationContext reactContext, + RequestListener listener, + DiskCacheConfig diskCacheConfig) { + super(reactContext); + mRequestListener = listener; + mDiskCacheConfig = diskCacheConfig; + } + @Override public void initialize() { super.initialize(); @@ -70,11 +81,18 @@ public class FrescoModule extends ReactContextBaseJavaModule implements Context context = this.getReactApplicationContext().getApplicationContext(); OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient(); - ImagePipelineConfig config = OkHttpImagePipelineConfigFactory - .newBuilder(context, okHttpClient) + ImagePipelineConfig.Builder builder = + OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient); + + builder .setDownsampleEnabled(false) - .setRequestListeners(requestListeners) - .build(); + .setRequestListeners(requestListeners); + + if (mDiskCacheConfig != null) { + builder.setMainDiskCacheConfig(mDiskCacheConfig); + } + + ImagePipelineConfig config = builder.build(); Fresco.initialize(context, config); }