-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC][RNTester] Move Flipper init out of app code #28052
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
68 changes: 68 additions & 0 deletions
68
ReactAndroid/src/debug/java/com/facebook/react/FlipperInitializer.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,68 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* 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.react; | ||
|
||
import android.content.Context; | ||
|
||
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.fresco.FrescoFlipperPlugin; | ||
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.bridge.ReactContext; | ||
import com.facebook.react.modules.network.NetworkingModule; | ||
|
||
import okhttp3.OkHttpClient; | ||
|
||
public class FlipperInitializer { | ||
public static void initializeDefaultFlipperPlugins( | ||
Context context, FlipperClient client, ReactInstanceManager reactInstanceManager) { | ||
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(); | ||
|
||
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized | ||
// Hence we run if after all native modules have been initialized | ||
ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); | ||
if (reactContext == null) { | ||
reactInstanceManager.addReactInstanceEventListener( | ||
new ReactInstanceManager.ReactInstanceEventListener() { | ||
@Override | ||
public void onReactContextInitialized(ReactContext reactContext) { | ||
reactInstanceManager.removeReactInstanceEventListener(this); | ||
reactContext.runOnNativeModulesQueueThread( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
client.addPlugin(new FrescoFlipperPlugin()); | ||
} | ||
}); | ||
} | ||
}); | ||
} else { | ||
client.addPlugin(new FrescoFlipperPlugin()); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is swipe refresh used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In React core itself. I wanted to have looked into this but haven't had a chance yet. Somehow the swipe layout no longer compiles now without explicitly depending on it here.