forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move fabric.Binding* to Kotlin (facebook#44438)
Summary: Pull Request resolved: facebook#44438 # Changelog: [Internal] - As in the title. Differential Revision: D57046289
- Loading branch information
1 parent
47848ad
commit 0d819c9
Showing
5 changed files
with
186 additions
and
191 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
69 changes: 0 additions & 69 deletions
69
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.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,72 @@ | ||
/* | ||
* 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.facebook.react.fabric | ||
|
||
import com.facebook.react.bridge.NativeMap | ||
import com.facebook.react.bridge.ReadableNativeMap | ||
import com.facebook.react.bridge.RuntimeExecutor | ||
import com.facebook.react.bridge.RuntimeScheduler | ||
import com.facebook.react.fabric.events.EventBeatManager | ||
import com.facebook.react.fabric.events.EventEmitterWrapper | ||
|
||
public interface Binding { | ||
public fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap) | ||
|
||
public fun startSurfaceWithConstraints( | ||
surfaceId: Int, | ||
moduleName: String?, | ||
initialProps: NativeMap?, | ||
minWidth: Float, | ||
maxWidth: Float, | ||
minHeight: Float, | ||
maxHeight: Float, | ||
offsetX: Float, | ||
offsetY: Float, | ||
isRTL: Boolean, | ||
doLeftAndRightSwapInRTL: Boolean | ||
) | ||
|
||
public fun stopSurface(surfaceId: Int) | ||
|
||
public fun setPixelDensity(pointScaleFactor: Float) | ||
|
||
public fun setConstraints( | ||
surfaceId: Int, | ||
minWidth: Float, | ||
maxWidth: Float, | ||
minHeight: Float, | ||
maxHeight: Float, | ||
offsetX: Float, | ||
offsetY: Float, | ||
isRTL: Boolean, | ||
doLeftAndRightSwapInRTL: Boolean | ||
) | ||
|
||
public fun driveCxxAnimations() | ||
|
||
public fun reportMount(surfaceId: Int) | ||
|
||
public fun getInspectorDataForInstance( | ||
eventEmitterWrapper: EventEmitterWrapper? | ||
): ReadableNativeMap? | ||
|
||
public fun register( | ||
runtimeExecutor: RuntimeExecutor, | ||
runtimeScheduler: RuntimeScheduler, | ||
fabricUIManager: FabricUIManager, | ||
eventBeatManager: EventBeatManager, | ||
componentFactory: ComponentFactory, | ||
reactNativeConfig: ReactNativeConfig | ||
) | ||
|
||
public fun unregister() | ||
|
||
public fun registerSurface(surfaceHandler: SurfaceHandlerBinding?) | ||
|
||
public fun unregisterSurface(surfaceHandler: SurfaceHandlerBinding?) | ||
} |
121 changes: 0 additions & 121 deletions
121
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/BindingImpl.java
This file was deleted.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/BindingImpl.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,113 @@ | ||
/* | ||
* 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.facebook.react.fabric | ||
|
||
import android.annotation.SuppressLint | ||
import com.facebook.jni.HybridData | ||
import com.facebook.proguard.annotations.DoNotStrip | ||
import com.facebook.react.bridge.NativeMap | ||
import com.facebook.react.bridge.ReadableNativeMap | ||
import com.facebook.react.bridge.RuntimeExecutor | ||
import com.facebook.react.bridge.RuntimeScheduler | ||
import com.facebook.react.common.mapbuffer.MapBufferSoLoader | ||
import com.facebook.react.fabric.events.EventBeatManager | ||
import com.facebook.react.fabric.events.EventEmitterWrapper | ||
import com.facebook.react.uimanager.PixelUtil.getDisplayMetricDensity | ||
|
||
@DoNotStrip | ||
@SuppressLint("MissingNativeLoadLibrary") | ||
public class BindingImpl : Binding { | ||
@DoNotStrip private val hybridData: HybridData = initHybrid() | ||
|
||
private external fun installFabricUIManager( | ||
runtimeExecutor: RuntimeExecutor, | ||
runtimeScheduler: RuntimeScheduler, | ||
uiManager: FabricUIManager, | ||
eventBeatManager: EventBeatManager, | ||
componentsRegistry: ComponentFactory, | ||
reactNativeConfig: Any | ||
) | ||
|
||
external override fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap) | ||
|
||
external override fun startSurfaceWithConstraints( | ||
surfaceId: Int, | ||
moduleName: String?, | ||
initialProps: NativeMap?, | ||
minWidth: Float, | ||
maxWidth: Float, | ||
minHeight: Float, | ||
maxHeight: Float, | ||
offsetX: Float, | ||
offsetY: Float, | ||
isRTL: Boolean, | ||
doLeftAndRightSwapInRTL: Boolean | ||
) | ||
|
||
external override fun stopSurface(surfaceId: Int) | ||
|
||
external override fun setPixelDensity(pointScaleFactor: Float) | ||
|
||
external override fun setConstraints( | ||
surfaceId: Int, | ||
minWidth: Float, | ||
maxWidth: Float, | ||
minHeight: Float, | ||
maxHeight: Float, | ||
offsetX: Float, | ||
offsetY: Float, | ||
isRTL: Boolean, | ||
doLeftAndRightSwapInRTL: Boolean | ||
) | ||
|
||
external override fun driveCxxAnimations() | ||
|
||
external override fun reportMount(surfaceId: Int) | ||
|
||
external override fun getInspectorDataForInstance( | ||
eventEmitterWrapper: EventEmitterWrapper? | ||
): ReadableNativeMap? | ||
|
||
override fun register( | ||
runtimeExecutor: RuntimeExecutor, | ||
runtimeScheduler: RuntimeScheduler, | ||
fabricUIManager: FabricUIManager, | ||
eventBeatManager: EventBeatManager, | ||
componentFactory: ComponentFactory, | ||
reactNativeConfig: ReactNativeConfig | ||
) { | ||
fabricUIManager.setBinding(this) | ||
installFabricUIManager( | ||
runtimeExecutor, | ||
runtimeScheduler, | ||
fabricUIManager, | ||
eventBeatManager, | ||
componentFactory, | ||
reactNativeConfig) | ||
setPixelDensity(getDisplayMetricDensity()) | ||
} | ||
|
||
private external fun uninstallFabricUIManager() | ||
|
||
override fun unregister() { | ||
uninstallFabricUIManager() | ||
} | ||
|
||
external override fun registerSurface(surfaceHandler: SurfaceHandlerBinding?) | ||
|
||
external override fun unregisterSurface(surfaceHandler: SurfaceHandlerBinding?) | ||
|
||
private companion object { | ||
init { | ||
FabricSoLoader.staticInit() | ||
MapBufferSoLoader.staticInit() | ||
} | ||
|
||
private external fun initHybrid(): HybridData | ||
} | ||
} |