mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 20:44:10 +00:00
Force fresco to go to network
Differential Revision: D2619848 fb-gh-sync-id: fe607dd8774c0c5f7122c362d64e4484c0bcce59
This commit is contained in:
parent
7f93548489
commit
575a4a71b9
@ -15,6 +15,7 @@ import android.content.Context;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.facebook.cache.common.CacheKey;
|
import com.facebook.cache.common.CacheKey;
|
||||||
|
import com.facebook.cache.disk.DiskCacheConfig;
|
||||||
import com.facebook.common.internal.AndroidPredicates;
|
import com.facebook.common.internal.AndroidPredicates;
|
||||||
import com.facebook.common.soloader.SoLoaderShim;
|
import com.facebook.common.soloader.SoLoaderShim;
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
@ -39,6 +40,7 @@ public class FrescoModule extends ReactContextBaseJavaModule implements
|
|||||||
ModuleDataCleaner.Cleanable {
|
ModuleDataCleaner.Cleanable {
|
||||||
|
|
||||||
@Nullable RequestListener mRequestListener;
|
@Nullable RequestListener mRequestListener;
|
||||||
|
@Nullable DiskCacheConfig mDiskCacheConfig;
|
||||||
|
|
||||||
public FrescoModule(ReactApplicationContext reactContext) {
|
public FrescoModule(ReactApplicationContext reactContext) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
@ -49,6 +51,15 @@ public class FrescoModule extends ReactContextBaseJavaModule implements
|
|||||||
mRequestListener = listener;
|
mRequestListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FrescoModule(
|
||||||
|
ReactApplicationContext reactContext,
|
||||||
|
RequestListener listener,
|
||||||
|
DiskCacheConfig diskCacheConfig) {
|
||||||
|
super(reactContext);
|
||||||
|
mRequestListener = listener;
|
||||||
|
mDiskCacheConfig = diskCacheConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
@ -70,11 +81,18 @@ public class FrescoModule extends ReactContextBaseJavaModule implements
|
|||||||
|
|
||||||
Context context = this.getReactApplicationContext().getApplicationContext();
|
Context context = this.getReactApplicationContext().getApplicationContext();
|
||||||
OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
|
OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
|
||||||
ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
|
ImagePipelineConfig.Builder builder =
|
||||||
.newBuilder(context, okHttpClient)
|
OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
|
||||||
|
|
||||||
|
builder
|
||||||
.setDownsampleEnabled(false)
|
.setDownsampleEnabled(false)
|
||||||
.setRequestListeners(requestListeners)
|
.setRequestListeners(requestListeners);
|
||||||
.build();
|
|
||||||
|
if (mDiskCacheConfig != null) {
|
||||||
|
builder.setMainDiskCacheConfig(mDiskCacheConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImagePipelineConfig config = builder.build();
|
||||||
Fresco.initialize(context, config);
|
Fresco.initialize(context, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user