mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Cleanup the Kotlin code in the .defaults package
Summary: With the IDE autocompletion now working \o/ I was able to apply some suggestions to the Kotlin code I wrote inside the .defaults package (like remove redudant qualifiers and similar). Changelog: [Internal] [Changed] - Cleanup the Kotlin code in the .defaults package Reviewed By: cipolleschi Differential Revision: D39348983 fbshipit-source-id: b443a6be179c85d2a4f4293051c4f26af93eb5f1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5e1c4d4203
commit
5cb02ee5be
@@ -46,7 +46,7 @@ class DefaultJSIModulePackage(private val reactNativeHost: ReactNativeHost) : JS
|
||||
DefaultComponentsRegistry.register(componentFactory)
|
||||
|
||||
val viewManagers =
|
||||
reactNativeHost.getReactInstanceManager().getOrCreateViewManagers(reactApplicationContext)
|
||||
reactNativeHost.reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)
|
||||
val viewManagerRegistry = ViewManagerRegistry(viewManagers)
|
||||
return FabricJSIModuleProvider(
|
||||
reactApplicationContext,
|
||||
|
||||
+3
-3
@@ -25,8 +25,8 @@ import com.facebook.react.ReactRootView
|
||||
open class DefaultReactActivityDelegate(
|
||||
activity: ReactActivity,
|
||||
mainComponentName: String,
|
||||
val fabricEnabled: Boolean = false,
|
||||
val concurrentRootEnabled: Boolean = false
|
||||
private val fabricEnabled: Boolean = false,
|
||||
private val concurrentRootEnabled: Boolean = false
|
||||
) : ReactActivityDelegate(activity, mainComponentName) {
|
||||
|
||||
/**
|
||||
@@ -42,5 +42,5 @@ open class DefaultReactActivityDelegate(
|
||||
}
|
||||
|
||||
override fun createRootView(): ReactRootView =
|
||||
ReactRootView(getContext()).apply { setIsFabric(fabricEnabled) }
|
||||
ReactRootView(context).apply { setIsFabric(fabricEnabled) }
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ import com.facebook.react.bridge.JSIModulePackage
|
||||
abstract class DefaultReactNativeHost protected constructor(application: Application) :
|
||||
ReactNativeHost(application) {
|
||||
|
||||
protected override fun getReactPackageTurboModuleManagerDelegateBuilder():
|
||||
override fun getReactPackageTurboModuleManagerDelegateBuilder():
|
||||
ReactPackageTurboModuleManagerDelegate.Builder? =
|
||||
dynamicLibraryName?.let {
|
||||
// If the user provided a dynamic library name, we assume they want to load
|
||||
// the default ReactPackageTurboModuleManagerDelegate
|
||||
DefaultTurboModuleManagerDelegate.Builder(it)
|
||||
DefaultTurboModuleManagerDelegate.Builder()
|
||||
}
|
||||
|
||||
protected override fun getJSIModulePackage(): JSIModulePackage? =
|
||||
override fun getJSIModulePackage(): JSIModulePackage? =
|
||||
dynamicLibraryName?.let {
|
||||
// If the user provided a dynamic library name, we assume they want to load
|
||||
// the default JSIModulePackage
|
||||
|
||||
+8
-31
@@ -12,46 +12,23 @@ import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.ReactPackage
|
||||
import com.facebook.react.ReactPackageTurboModuleManagerDelegate
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.soloader.SoLoader
|
||||
|
||||
/**
|
||||
* A utility class that allows you to provide a TurboModuleManagerDelegate by just specifying the
|
||||
* name of the dynamic library. This class will take care of loading the dynamic library for you on
|
||||
* your behalf.
|
||||
* A utility class that allows you to simplify the setup of a
|
||||
* [ReactPackageTurboModuleManagerDelegate] for new apps in Open Source.
|
||||
*
|
||||
* Please note that you need to provide a native implementation for the method initHybrid for this
|
||||
* class, making sure the Java Descriptor is:
|
||||
* Lcom/facebook/react/defaults/DefaultTurboModuleManagerDelegate;
|
||||
*/
|
||||
class DefaultTurboModuleManagerDelegate
|
||||
private constructor(
|
||||
dynamicLibraryName: String,
|
||||
context: ReactApplicationContext,
|
||||
packages: List<ReactPackage>
|
||||
) : ReactPackageTurboModuleManagerDelegate(context, packages) {
|
||||
private constructor(context: ReactApplicationContext, packages: List<ReactPackage>) :
|
||||
ReactPackageTurboModuleManagerDelegate(context, packages) {
|
||||
|
||||
@DoNotStrip protected override external fun initHybrid(): HybridData?
|
||||
@DoNotStrip external override fun initHybrid(): HybridData?
|
||||
|
||||
init {
|
||||
maybeLoadOtherSoLibraries(dynamicLibraryName)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun maybeLoadOtherSoLibraries(dynamicLibraryName: String) {
|
||||
// Prevents issues with initializer interruptions.
|
||||
if (!isSoLibraryLoaded) {
|
||||
SoLoader.loadLibrary(dynamicLibraryName)
|
||||
isSoLibraryLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
class Builder(private val dynamicLibraryName: String) :
|
||||
ReactPackageTurboModuleManagerDelegate.Builder() {
|
||||
protected override fun build(context: ReactApplicationContext, packages: List<ReactPackage>) =
|
||||
DefaultTurboModuleManagerDelegate(dynamicLibraryName, context, packages)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Volatile private var isSoLibraryLoaded = false
|
||||
class Builder : ReactPackageTurboModuleManagerDelegate.Builder() {
|
||||
override fun build(context: ReactApplicationContext, packages: List<ReactPackage>) =
|
||||
DefaultTurboModuleManagerDelegate(context, packages)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user