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.
Migrate PreAllocateViewMountItem to Kotlin (facebook#47258)
Summary: Pull Request resolved: facebook#47258 Migrate PreAllocateViewMountItem to Kotlin changeLog: [internal] internal Reviewed By: shwanton Differential Revision: D65070220
- Loading branch information
Showing
2 changed files
with
63 additions
and
90 deletions.
There are no files selected for viewing
90 changes: 0 additions & 90 deletions
90
...src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.java
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
...d/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.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,63 @@ | ||
/* | ||
* 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.mounting.mountitems | ||
|
||
import com.facebook.common.logging.FLog | ||
import com.facebook.react.bridge.ReadableMap | ||
import com.facebook.react.fabric.FabricUIManager | ||
import com.facebook.react.fabric.mounting.MountingManager | ||
import com.facebook.react.fabric.mounting.mountitems.FabricNameComponentMapping.getFabricComponentName | ||
import com.facebook.react.uimanager.StateWrapper | ||
|
||
/** [MountItem] that is used to pre-allocate views for JS components. */ | ||
internal class PreAllocateViewMountItem( | ||
private val surfaceId: Int, | ||
private val reactTag: Int, | ||
component: String, | ||
private val props: ReadableMap?, | ||
private val stateWrapper: StateWrapper?, | ||
private val isLayoutable: Boolean | ||
) : MountItem { | ||
private val fabricComponentName = getFabricComponentName(component) | ||
|
||
override fun getSurfaceId(): Int = surfaceId | ||
|
||
override fun execute(mountingManager: MountingManager) { | ||
val surfaceMountingManager = mountingManager.getSurfaceManager(surfaceId) | ||
if (surfaceMountingManager == null) { | ||
FLog.e( | ||
FabricUIManager.TAG, | ||
"Skipping View PreAllocation; no SurfaceMountingManager found for [$surfaceId]") | ||
return | ||
} | ||
surfaceMountingManager.preallocateView( | ||
fabricComponentName, reactTag, props, stateWrapper, isLayoutable) | ||
} | ||
|
||
override fun toString(): String { | ||
val result = | ||
StringBuilder("PreAllocateViewMountItem [") | ||
.append(reactTag) | ||
.append("] - component: ") | ||
.append(fabricComponentName) | ||
.append(" surfaceId: ") | ||
.append(surfaceId) | ||
.append(" isLayoutable: ") | ||
.append(isLayoutable) | ||
|
||
if (FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT) { | ||
result | ||
.append(" props: ") | ||
.append(props?.toString() ?: "<null>") | ||
.append(" state: ") | ||
.append(stateWrapper?.toString() ?: "<null>") | ||
} | ||
|
||
return result.toString() | ||
} | ||
} |