From ba661bd7cfcc4e356b4dc395e02c6e965af0653a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Guzm=C3=A1n?= Date: Tue, 11 Mar 2025 23:15:57 +0100 Subject: [PATCH 1/2] Migrate ViewAtIndex to Kotlin --- .../facebook/react/uimanager/ViewAtIndex.java | 46 ------------------- .../facebook/react/uimanager/ViewAtIndex.kt | 31 +++++++++++++ 2 files changed, 31 insertions(+), 46 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.java deleted file mode 100644 index 3ad0bc67baf743..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.uimanager; - -import java.util.Comparator; - -/** - * Data structure that couples view tag to it's index in parent view. Used for managing children - * operation. - */ -public class ViewAtIndex { - public static Comparator COMPARATOR = - new Comparator() { - @Override - public int compare(ViewAtIndex lhs, ViewAtIndex rhs) { - return lhs.mIndex - rhs.mIndex; - } - }; - - public final int mTag; - public final int mIndex; - - public ViewAtIndex(int tag, int index) { - mTag = tag; - mIndex = index; - } - - @Override - public boolean equals(Object obj) { - if (obj == null || obj.getClass() != getClass()) { - return false; - } - ViewAtIndex other = (ViewAtIndex) obj; - return mIndex == other.mIndex && mTag == other.mTag; - } - - @Override - public String toString() { - return "[" + mTag + ", " + mIndex + "]"; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt new file mode 100644 index 00000000000000..48b42f2bdabeb4 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt @@ -0,0 +1,31 @@ +/* + * 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.uimanager + +/** + * Data structure that couples view tag to it's index in parent view. Used for managing children + * operation. + */ +public class ViewAtIndex public constructor(@JvmField public val mTag: Int, @JvmField public val mIndex: Int) { + override fun equals(obj: Any?): Boolean { + if (obj == null || obj.javaClass != javaClass) { + return false + } + val other = obj as ViewAtIndex + return mIndex == other.mIndex && mTag == other.mTag + } + + override fun toString(): String { + return "[$mTag, $mIndex]" + } + + public companion object { + @JvmField + public var COMPARATOR: Comparator = + Comparator { lhs, rhs -> lhs.mIndex - rhs.mIndex } + } +} From 8c8a3d483819ac3fd1810bfa5193c3b62aafdbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Guzm=C3=A1n?= Date: Tue, 11 Mar 2025 23:34:41 +0100 Subject: [PATCH 2/2] Revert newArchEnabled --- .../src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt | 1 + packages/rn-tester/android/app/gradle.properties | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt index 2a4948d577c7d3..c46b6eb32b3754 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewAtIndex.kt @@ -4,6 +4,7 @@ * 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.uimanager import com.facebook.react.common.annotations.internal.LegacyArchitecture diff --git a/packages/rn-tester/android/app/gradle.properties b/packages/rn-tester/android/app/gradle.properties index 2dbb1b8c945452..cadd03ba6faaa3 100644 --- a/packages/rn-tester/android/app/gradle.properties +++ b/packages/rn-tester/android/app/gradle.properties @@ -4,6 +4,6 @@ org.gradle.parallel=true android.useAndroidX=true # RN-Tester is building with NewArch always enabled -newArchEnabled=false +newArchEnabled=true # RN-Tester is running with Hermes enabled and filtering variants with enableHermesOnlyInVariants hermesEnabled=true