Force fresco to go to network

Differential Revision: D2619848

fb-gh-sync-id: fe607dd8774c0c5f7122c362d64e4484c0bcce59
This commit is contained in:
Mike Armstrong 2015-11-04 19:21:14 -08:00 committed by facebook-github-bot-6
parent 7f93548489
commit 575a4a71b9
1 changed files with 22 additions and 4 deletions

View File

@ -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);
}