diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 8afeee79e05f9f..8fa2a53b5365d9 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -5563,11 +5563,9 @@ public class com/facebook/react/uimanager/events/BlackHoleEventDispatcher : com/ public fun unregisterEventEmitter (I)V } -public class com/facebook/react/uimanager/events/ContentSizeChangeEvent : com/facebook/react/uimanager/events/Event { - public static final field EVENT_NAME Ljava/lang/String; +public final class com/facebook/react/uimanager/events/ContentSizeChangeEvent : com/facebook/react/uimanager/events/Event { public fun (III)V public fun (IIII)V - 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/uimanager/events/ContentSizeChangeEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ContentSizeChangeEvent.java deleted file mode 100644 index 09870620d04bc9..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ContentSizeChangeEvent.java +++ /dev/null @@ -1,52 +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.events; - -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.WritableMap; -import com.facebook.react.uimanager.PixelUtil; - -/** - * Event dispatched when total width or height of a view's children changes. - * - * @deprecated Please define your own event for custom components - */ -@Nullsafe(Nullsafe.Mode.LOCAL) -@Deprecated -public class ContentSizeChangeEvent extends Event { - - public static final String EVENT_NAME = "topContentSizeChange"; - - private final int mWidth; - private final int mHeight; - - @Deprecated - public ContentSizeChangeEvent(int viewTag, int width, int height) { - this(-1, viewTag, width, height); - } - - public ContentSizeChangeEvent(int surfaceId, int viewTag, int width, int height) { - super(surfaceId, viewTag); - mWidth = width; - mHeight = height; - } - - @Override - public String getEventName() { - return EVENT_NAME; - } - - @Override - protected WritableMap getEventData() { - WritableMap data = Arguments.createMap(); - data.putDouble("width", PixelUtil.toDIPFromPixel(mWidth)); - data.putDouble("height", PixelUtil.toDIPFromPixel(mHeight)); - return data; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ContentSizeChangeEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ContentSizeChangeEvent.kt new file mode 100644 index 00000000000000..64faa2dff73f93 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ContentSizeChangeEvent.kt @@ -0,0 +1,41 @@ +/* + * 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. + */ + +@file:Suppress("DEPRECATION") + +package com.facebook.react.uimanager.events + +import com.facebook.react.bridge.Arguments +import com.facebook.react.bridge.WritableMap +import com.facebook.react.uimanager.PixelUtil.toDIPFromPixel + +/** Event dispatched when total width or height of a view's children changes. */ +@Deprecated("Please define your own event for custom components") +public class ContentSizeChangeEvent( + surfaceId: Int, + viewTag: Int, + private val width: Int, + private val height: Int +) : Event(surfaceId, viewTag) { + @Deprecated( + "Please specify surfaceId explicitly in the constructor.", + ReplaceWith("constructor(surfaceId, viewTag, width, height)")) + public constructor(viewTag: Int, width: Int, height: Int) : this(-1, viewTag, width, height) + + public override fun getEventName(): String = EVENT_NAME + + protected override fun getEventData(): WritableMap { + val res = Arguments.createMap() + res.putDouble("width", toDIPFromPixel(width.toFloat()).toDouble()) + res.putDouble("height", toDIPFromPixel(height.toFloat()).toDouble()) + return res + } + + private companion object { + private const val EVENT_NAME: String = "topContentSizeChange" + } +}