Migrate ViewAtIndex to Kotlin (#49963)

Summary:
Migrate com.facebook.react.uimanager.ViewAtIndex to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.ViewAtIndex to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/49963

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: cortinico

Differential Revision: D71031245

Pulled By: javache

fbshipit-source-id: eb9d4fd59a6017b9ef65b239ee73697b476df8f2
This commit is contained in:
Mateo Guzmán
2025-03-13 05:28:50 -07:00
committed by Facebook GitHub Bot
parent b226049a4a
commit a9babf9bc9
3 changed files with 54 additions and 56 deletions
@@ -4852,15 +4852,20 @@ public abstract interface class com/facebook/react/uimanager/UIViewOperationQueu
public abstract fun execute ()V
}
public class com/facebook/react/uimanager/ViewAtIndex {
public final class com/facebook/react/uimanager/ViewAtIndex {
public static field COMPARATOR Ljava/util/Comparator;
public static final field Companion Lcom/facebook/react/uimanager/ViewAtIndex$Companion;
public final field mIndex I
public final field mTag I
public fun <init> (II)V
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
public final class com/facebook/react/uimanager/ViewAtIndex$Companion {
}
public final class com/facebook/react/uimanager/ViewDefaults {
public static final field FONT_SIZE_SP F
public static final field INSTANCE Lcom/facebook/react/uimanager/ViewDefaults;
@@ -1,55 +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 com.facebook.react.common.annotations.internal.LegacyArchitecture;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import java.util.Comparator;
/**
* Data structure that couples view tag to it's index in parent view. Used for managing children
* operation.
*/
@LegacyArchitecture
public class ViewAtIndex {
static {
LegacyArchitectureLogger.assertWhenLegacyArchitectureMinifyingEnabled(
"ViewAtIndex", LegacyArchitectureLogLevel.WARNING);
}
public static Comparator<ViewAtIndex> COMPARATOR =
new Comparator<ViewAtIndex>() {
@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 + "]";
}
}
@@ -0,0 +1,48 @@
/*
* 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 com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
import java.util.Objects
/**
* Data structure that couples view tag to it's index in parent view. Used for managing children
* operation.
*/
@LegacyArchitecture
public class ViewAtIndex(
@Suppress("NoHungarianNotation") @JvmField public val mTag: Int,
@Suppress("NoHungarianNotation") @JvmField public val mIndex: Int
) {
override fun equals(other: Any?): Boolean {
if (other == null || other.javaClass != javaClass) {
return false
}
val otherViewAtIndex = other as ViewAtIndex
return mIndex == otherViewAtIndex.mIndex && mTag == otherViewAtIndex.mTag
}
override fun hashCode(): Int = Objects.hash(mTag, mIndex)
override fun toString(): String = "[$mTag, $mIndex]"
public companion object {
@JvmField
public var COMPARATOR: Comparator<ViewAtIndex> = Comparator { lhs, rhs ->
lhs.mIndex - rhs.mIndex
}
init {
LegacyArchitectureLogger.assertWhenLegacyArchitectureMinifyingEnabled(
"ViewAtIndex", LegacyArchitectureLogLevel.WARNING)
}
}
}