MCPcopy Create free account
hub / github.com/KbamApp/kbam / ReactNativeFlipper

Class ReactNativeFlipper

android/app/src/debug/java/com/kbam/ReactNativeFlipper.java:31–75  ·  view source on GitHub ↗

Class responsible of loading Flipper inside your React Native application. This is the debug flavor of it. Here you can add your own plugins and customize the Flipper setup.

Source from the content-addressed store, hash-verified

29 * flavor of it. Here you can add your own plugins and customize the Flipper setup.
30 */
31public class ReactNativeFlipper {
32 public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
33 if (FlipperUtils.shouldEnableFlipper(context)) {
34 final FlipperClient client = AndroidFlipperClient.getInstance(context);
35
36 client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
37 client.addPlugin(new DatabasesFlipperPlugin(context));
38 client.addPlugin(new SharedPreferencesFlipperPlugin(context));
39 client.addPlugin(CrashReporterPlugin.getInstance());
40
41 NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
42 NetworkingModule.setCustomClientBuilder(
43 new NetworkingModule.CustomClientBuilder() {
44 @Override
45 public void apply(OkHttpClient.Builder builder) {
46 builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
47 }
48 });
49 client.addPlugin(networkFlipperPlugin);
50 client.start();
51
52 // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
53 // Hence we run if after all native modules have been initialized
54 ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
55 if (reactContext == null) {
56 reactInstanceManager.addReactInstanceEventListener(
57 new ReactInstanceEventListener() {
58 @Override
59 public void onReactContextInitialized(ReactContext reactContext) {
60 reactInstanceManager.removeReactInstanceEventListener(this);
61 reactContext.runOnNativeModulesQueueThread(
62 new Runnable() {
63 @Override
64 public void run() {
65 client.addPlugin(new FrescoFlipperPlugin());
66 }
67 });
68 }
69 });
70 } else {
71 client.addPlugin(new FrescoFlipperPlugin());
72 }
73 }
74 }
75}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected