-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
804 additions
and
294 deletions.
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
75 changes: 0 additions & 75 deletions
75
BrazeProject/android/app/src/debug/java/com/brazeproject/ReactNativeFlipper.java
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
BrazeProject/android/app/src/debug/java/com/brazeproject/ReactNativeFlipper.kt
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) Meta Platforms, Inc. and 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.brazeproject | ||
|
||
import android.content.Context | ||
import com.facebook.flipper.android.AndroidFlipperClient | ||
import com.facebook.flipper.android.utils.FlipperUtils | ||
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.sharedpreferences.SharedPreferencesFlipperPlugin | ||
import com.facebook.react.ReactInstanceEventListener | ||
import com.facebook.react.ReactInstanceManager | ||
import com.facebook.react.bridge.ReactContext | ||
import com.facebook.react.modules.network.NetworkingModule | ||
|
||
/** | ||
* 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. | ||
*/ | ||
object ReactNativeFlipper { | ||
@JvmStatic | ||
fun initializeFlipper(context: Context?, reactInstanceManager: ReactInstanceManager) { | ||
if (FlipperUtils.shouldEnableFlipper(context)) { | ||
val client = AndroidFlipperClient.getInstance(context) | ||
client.addPlugin(InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())) | ||
client.addPlugin(DatabasesFlipperPlugin(context)) | ||
client.addPlugin(SharedPreferencesFlipperPlugin(context)) | ||
client.addPlugin(CrashReporterPlugin.getInstance()) | ||
val networkFlipperPlugin = NetworkFlipperPlugin() | ||
NetworkingModule.setCustomClientBuilder { builder -> | ||
builder.addNetworkInterceptor( | ||
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 | ||
val reactContext = reactInstanceManager.currentReactContext | ||
if (reactContext == null) { | ||
reactInstanceManager.addReactInstanceEventListener( | ||
object : ReactInstanceEventListener { | ||
override fun onReactContextInitialized(reactContext: ReactContext) { | ||
reactInstanceManager.removeReactInstanceEventListener(this) | ||
reactContext.runOnNativeModulesQueueThread { | ||
client.addPlugin( | ||
FrescoFlipperPlugin() | ||
) | ||
} | ||
} | ||
}) | ||
} else { | ||
client.addPlugin(FrescoFlipperPlugin()) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.