From 605a52fe3ec099b652fc222947d1ddffa41cfd7f Mon Sep 17 00:00:00 2001 From: Alexander Oprisnik Date: Wed, 7 Dec 2022 10:35:01 -0800 Subject: [PATCH] Added possibility to mark Fresco image pipeline as already initialized for RN apps Summary: Changelog: [Android][Added] - Added possibility to mark Fresco image pipeline as already initialized Reviewed By: defHLT Differential Revision: D41741638 fbshipit-source-id: 46f059297f3af8c1f9cb4b93ce4add895bce85df --- .../react/modules/fresco/FrescoModule.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 b47c4d15a09..354871205aa 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 @@ -77,9 +77,31 @@ public class FrescoModule extends ReactContextBaseJavaModule * @param reactContext the context to use */ public FrescoModule( - ReactApplicationContext reactContext, ImagePipeline imagePipeline, boolean clearOnDestroy) { + ReactApplicationContext reactContext, + @Nullable ImagePipeline imagePipeline, + boolean clearOnDestroy) { + this(reactContext, imagePipeline, clearOnDestroy, false); + } + + /** + * Create a new Fresco module with a default configuration (or the previously given configuration + * via {@link #FrescoModule(ReactApplicationContext, boolean, ImagePipelineConfig)}. + * + * @param clearOnDestroy whether to clear the memory cache in onHostDestroy: this should be {@code + * true} for pure RN apps and {@code false} for apps that use Fresco outside of RN as well + * @param reactContext the context to use + * @param hasBeenInitializedExternally whether Fresco has already been initialized + */ + public FrescoModule( + ReactApplicationContext reactContext, + @Nullable ImagePipeline imagePipeline, + boolean clearOnDestroy, + boolean hasBeenInitializedExternally) { this(reactContext, clearOnDestroy); mImagePipeline = imagePipeline; + if (hasBeenInitializedExternally) { + sHasBeenInitialized = true; + } } /**