-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Flipper to React Native OSS by default
Reviewed By: passy Differential Revision: D6723578 fbshipit-source-id: f34442689f99cd94220335a171010224a12132a8
- Loading branch information
1 parent
a60e581
commit 3a66fc7
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
ReactAndroid/src/debug/java/com/facebook/flipper/ReactNativeFlipper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root | ||
* directory of this source tree. | ||
*/ | ||
package com.facebook.flipper; | ||
|
||
import android.content.Context; | ||
import com.facebook.flipper.android.AndroidFlipperClient; | ||
import com.facebook.flipper.android.utils.FlipperUtils; | ||
import com.facebook.flipper.core.FlipperClient; | ||
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; | ||
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; | ||
import com.facebook.flipper.plugins.inspector.DescriptorMapping; | ||
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; | ||
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; | ||
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; | ||
import com.facebook.flipper.plugins.react.ReactFlipperPlugin; | ||
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; | ||
import com.facebook.react.BuildConfig; | ||
import com.facebook.react.modules.network.NetworkingModule; | ||
import okhttp3.OkHttpClient; | ||
|
||
public class ReactNativeFlipper { | ||
public static final String CLASS_NAME = "com.facebook.flipper.ReactNativeFlipper"; | ||
|
||
public static void initializeFlipper(Context context) { | ||
if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(context)) { | ||
final FlipperClient client = AndroidFlipperClient.getInstance(context); | ||
|
||
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); | ||
client.addPlugin(new ReactFlipperPlugin()); | ||
client.addPlugin(new DatabasesFlipperPlugin(context)); | ||
client.addPlugin(new SharedPreferencesFlipperPlugin(context)); | ||
client.addPlugin(CrashReporterPlugin.getInstance()); | ||
|
||
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); | ||
NetworkingModule.setCustomClientBuilder( | ||
new NetworkingModule.CustomClientBuilder() { | ||
@Override | ||
public void apply(OkHttpClient.Builder builder) { | ||
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); | ||
} | ||
}); | ||
client.addPlugin(networkFlipperPlugin); | ||
|
||
client.start(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters