diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.java deleted file mode 100644 index f3073c928f3389..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.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.views.switchview; - -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; - -/** Event emitted by a ReactSwitchManager once a switch is fully switched on/off */ -/*package*/ @Nullsafe(Nullsafe.Mode.LOCAL) -class ReactSwitchEvent extends Event { - - public static final String EVENT_NAME = "topChange"; - - private final boolean mIsChecked; - - @Deprecated - public ReactSwitchEvent(int viewId, boolean isChecked) { - this(ViewUtil.NO_SURFACE_ID, viewId, isChecked); - } - - public ReactSwitchEvent(int surfaceId, int viewId, boolean isChecked) { - super(surfaceId, viewId); - mIsChecked = isChecked; - } - - public boolean getIsChecked() { - return mIsChecked; - } - - @Override - public String getEventName() { - return EVENT_NAME; - } - - @Nullable - @Override - protected WritableMap getEventData() { - WritableMap eventData = Arguments.createMap(); - eventData.putInt("target", getViewTag()); - eventData.putBoolean("value", getIsChecked()); - return eventData; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.kt new file mode 100644 index 00000000000000..eb0590a4dc63d1 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitchEvent.kt @@ -0,0 +1,38 @@ +/* + * 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.switchview + +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 + +/** Event emitted by a ReactSwitchManager once a switch is fully switched on/off */ +internal class ReactSwitchEvent(surfaceId: Int, viewId: Int, private val isChecked: Boolean) : + Event(surfaceId, viewId) { + + @Deprecated( + "Use the constructor with surfaceId, viewId and isChecked parameters.", + replaceWith = ReplaceWith("ReactSwitchEvent(surfaceId, viewId, isChecked)")) + constructor(viewId: Int, isChecked: Boolean) : this(ViewUtil.NO_SURFACE_ID, viewId, isChecked) + + public override fun getEventName(): String { + return EVENT_NAME + } + + public override fun getEventData(): WritableMap? { + val eventData = Arguments.createMap() + eventData.putInt("target", viewTag) + eventData.putBoolean("value", isChecked) + return eventData + } + + private companion object { + private const val EVENT_NAME = "topChange" + } +}