1
1
/**
2
- * Copyright (c) Facebook , Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms , Inc. and affiliates.
3
3
*
4
4
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
5
* directory of this source tree.
6
6
*/
7
7
package com .awesomeproject ;
8
-
9
8
import android .content .Context ;
10
9
import com .facebook .flipper .android .AndroidFlipperClient ;
11
10
import com .facebook .flipper .android .utils .FlipperUtils ;
19
18
import com .facebook .flipper .plugins .network .NetworkFlipperPlugin ;
20
19
import com .facebook .flipper .plugins .react .ReactFlipperPlugin ;
21
20
import com .facebook .flipper .plugins .sharedpreferences .SharedPreferencesFlipperPlugin ;
21
+ import com .facebook .react .ReactInstanceEventListener ;
22
22
import com .facebook .react .ReactInstanceManager ;
23
23
import com .facebook .react .bridge .ReactContext ;
24
24
import com .facebook .react .modules .network .NetworkingModule ;
25
25
import okhttp3 .OkHttpClient ;
26
-
27
26
public class ReactNativeFlipper {
28
27
public static void initializeFlipper (Context context , ReactInstanceManager reactInstanceManager ) {
29
28
if (FlipperUtils .shouldEnableFlipper (context )) {
30
29
final FlipperClient client = AndroidFlipperClient .getInstance (context );
31
-
32
30
client .addPlugin (new InspectorFlipperPlugin (context , DescriptorMapping .withDefaults ()));
33
31
client .addPlugin (new ReactFlipperPlugin ());
34
32
client .addPlugin (new DatabasesFlipperPlugin (context ));
35
33
client .addPlugin (new SharedPreferencesFlipperPlugin (context ));
36
34
client .addPlugin (CrashReporterPlugin .getInstance ());
37
-
38
35
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin ();
39
36
NetworkingModule .setCustomClientBuilder (
40
37
new NetworkingModule .CustomClientBuilder () {
@@ -45,13 +42,12 @@ public void apply(OkHttpClient.Builder builder) {
45
42
});
46
43
client .addPlugin (networkFlipperPlugin );
47
44
client .start ();
48
-
49
45
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50
46
// Hence we run if after all native modules have been initialized
51
47
ReactContext reactContext = reactInstanceManager .getCurrentReactContext ();
52
48
if (reactContext == null ) {
53
49
reactInstanceManager .addReactInstanceEventListener (
54
- new ReactInstanceManager . ReactInstanceEventListener () {
50
+ new ReactInstanceEventListener () {
55
51
@ Override
56
52
public void onReactContextInitialized (ReactContext reactContext ) {
57
53
reactInstanceManager .removeReactInstanceEventListener (this );
@@ -69,4 +65,4 @@ public void run() {
69
65
}
70
66
}
71
67
}
72
- }
68
+ }
0 commit comments