From d5dcaf3c1e3d53bba536555a2f30d720fa82a7a4 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Fri, 5 Apr 2024 13:47:44 -0700 Subject: [PATCH] Kotlinify DispatchStringCommandMountItem (#43870) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43870 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: alanleedev Differential Revision: D55752447 fbshipit-source-id: 1965cc39601f514d0664d4d73bff4546f7c0f170 --- .../DispatchStringCommandMountItem.java | 47 ------------------- .../DispatchStringCommandMountItem.kt | 27 +++++++++++ 2 files changed, 27 insertions(+), 47 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java deleted file mode 100644 index 4b68d18aef8..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.java +++ /dev/null @@ -1,47 +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.fabric.mounting.mountitems; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.fabric.mounting.MountingManager; - -@Nullsafe(Nullsafe.Mode.LOCAL) -final class DispatchStringCommandMountItem extends DispatchCommandMountItem { - - private final int mSurfaceId; - private final int mReactTag; - private final @NonNull String mCommandId; - private final @Nullable ReadableArray mCommandArgs; - - DispatchStringCommandMountItem( - int surfaceId, int reactTag, @NonNull String commandId, @Nullable ReadableArray commandArgs) { - mSurfaceId = surfaceId; - mReactTag = reactTag; - mCommandId = commandId; - mCommandArgs = commandArgs; - } - - @Override - public int getSurfaceId() { - return mSurfaceId; - } - - @Override - public void execute(@NonNull MountingManager mountingManager) { - mountingManager.receiveCommand(mSurfaceId, mReactTag, mCommandId, mCommandArgs); - } - - @Override - @NonNull - public String toString() { - return "DispatchStringCommandMountItem [" + mReactTag + "] " + mCommandId; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.kt new file mode 100644 index 00000000000..fc3bbebdf9a --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/DispatchStringCommandMountItem.kt @@ -0,0 +1,27 @@ +/* + * 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.react.bridge.ReadableArray +import com.facebook.react.fabric.mounting.MountingManager + +internal class DispatchStringCommandMountItem( + private val surfaceId: Int, + private val reactTag: Int, + private val commandId: String, + private val commandArgs: ReadableArray? +) : DispatchCommandMountItem() { + + override public fun getSurfaceId(): Int = surfaceId + + override public fun execute(mountingManager: MountingManager) { + mountingManager.receiveCommand(surfaceId, reactTag, commandId, commandArgs) + } + + override public fun toString(): String = "DispatchStringCommandMountItem [$reactTag] $commandId" +}