From a0d809cdd383594c7a20fae4bf8319ce5bfa4f02 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Fri, 5 Apr 2024 17:00:47 -0700 Subject: [PATCH] Kotlinify ViewGroupClickEvent (#43866) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43866 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: tdn120 Differential Revision: D55749364 fbshipit-source-id: 184c43da537e550842cb9a675c525fa18cdee9f6 --- .../ReactAndroid/api/ReactAndroid.api | 3 +- .../react/views/view/ViewGroupClickEvent.java | 46 ------------------- .../react/views/view/ViewGroupClickEvent.kt | 31 +++++++++++++ 3 files changed, 32 insertions(+), 48 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 4e609943101..52f2e1fc845 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -7810,11 +7810,10 @@ public class com/facebook/react/views/view/ReactViewManager$$PropsSetter : com/f public fun setProperty (Lcom/facebook/react/views/view/ReactViewManager;Lcom/facebook/react/views/view/ReactViewGroup;Ljava/lang/String;Ljava/lang/Object;)V } -public class com/facebook/react/views/view/ViewGroupClickEvent : com/facebook/react/uimanager/events/Event { +public final class com/facebook/react/views/view/ViewGroupClickEvent : com/facebook/react/uimanager/events/Event { public fun (I)V public fun (II)V public fun canCoalesce ()Z - protected fun getEventData ()Lcom/facebook/react/bridge/WritableMap; public fun getEventName ()Ljava/lang/String; } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.java deleted file mode 100644 index e6d7c0f10af..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.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.views.view; - -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.WritableMap; -import com.facebook.react.uimanager.common.ViewUtil; -import com.facebook.react.uimanager.events.Event; - -/** Represents a Click on the ReactViewGroup */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public class ViewGroupClickEvent extends Event { - private static final String EVENT_NAME = "topClick"; - - @Deprecated - public ViewGroupClickEvent(int viewId) { - this(ViewUtil.NO_SURFACE_ID, viewId); - } - - public ViewGroupClickEvent(int surfaceId, int viewId) { - super(surfaceId, viewId); - } - - @Override - public String getEventName() { - return EVENT_NAME; - } - - @Override - public boolean canCoalesce() { - return false; - } - - @Nullable - @Override - protected WritableMap getEventData() { - return Arguments.createMap(); - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.kt new file mode 100644 index 00000000000..dfcc5954783 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ViewGroupClickEvent.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.views.view + +import com.facebook.react.bridge.Arguments +import com.facebook.react.bridge.WritableMap +import com.facebook.react.uimanager.common.ViewUtil +import com.facebook.react.uimanager.events.Event + +/** Represents a Click on the ReactViewGroup */ +public class ViewGroupClickEvent(surfaceId: Int, viewId: Int) : + Event(surfaceId, viewId) { + + @Deprecated("Use the constructor with surfaceId and viewId parameters.") + public constructor(viewId: Int) : this(ViewUtil.NO_SURFACE_ID, viewId) + + override public fun getEventName(): String = EVENT_NAME + + override public fun canCoalesce(): Boolean = false + + override protected fun getEventData(): WritableMap = Arguments.createMap() + + private companion object { + private const val EVENT_NAME: String = "topClick" + } +}