Kotlinify ScrollEventType (#43827)

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

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: arushikesarwani94

Differential Revision: D55708353

fbshipit-source-id: 30a31e7eb9e6ad59b7c90468f9e6f55c91c579a8
This commit is contained in:
Fabrizio Cucci
2024-04-04 02:00:36 -07:00
committed by Facebook GitHub Bot
parent a97109ef2e
commit 1cbe5376ba
3 changed files with 35 additions and 38 deletions
@@ -6741,15 +6741,20 @@ public final class com/facebook/react/views/scroll/ScrollEvent$Companion {
public final class com/facebook/react/views/scroll/ScrollEventType : java/lang/Enum {
public static final field BEGIN_DRAG Lcom/facebook/react/views/scroll/ScrollEventType;
public static final field Companion Lcom/facebook/react/views/scroll/ScrollEventType$Companion;
public static final field END_DRAG Lcom/facebook/react/views/scroll/ScrollEventType;
public static final field MOMENTUM_BEGIN Lcom/facebook/react/views/scroll/ScrollEventType;
public static final field MOMENTUM_END Lcom/facebook/react/views/scroll/ScrollEventType;
public static final field SCROLL Lcom/facebook/react/views/scroll/ScrollEventType;
public static fun getJSEventName (Lcom/facebook/react/views/scroll/ScrollEventType;)Ljava/lang/String;
public static final fun getJSEventName (Lcom/facebook/react/views/scroll/ScrollEventType;)Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/views/scroll/ScrollEventType;
public static fun values ()[Lcom/facebook/react/views/scroll/ScrollEventType;
}
public final class com/facebook/react/views/scroll/ScrollEventType$Companion {
public final fun getJSEventName (Lcom/facebook/react/views/scroll/ScrollEventType;)Ljava/lang/String;
}
public class com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout : androidx/swiperefreshlayout/widget/SwipeRefreshLayout {
public fun <init> (Lcom/facebook/react/bridge/ReactContext;)V
public fun onInterceptTouchEvent (Landroid/view/MotionEvent;)Z
@@ -1,37 +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.scroll;
import com.facebook.infer.annotation.Nullsafe;
/** Scroll event types that JS module RCTEventEmitter can understand */
@Nullsafe(Nullsafe.Mode.LOCAL)
public enum ScrollEventType {
BEGIN_DRAG,
END_DRAG,
SCROLL,
MOMENTUM_BEGIN,
MOMENTUM_END;
public static String getJSEventName(ScrollEventType type) {
switch (type) {
case BEGIN_DRAG:
return "topScrollBeginDrag";
case END_DRAG:
return "topScrollEndDrag";
case SCROLL:
return "topScroll";
case MOMENTUM_BEGIN:
return "topMomentumScrollBegin";
case MOMENTUM_END:
return "topMomentumScrollEnd";
default:
throw new IllegalArgumentException("Unsupported ScrollEventType: " + type);
}
}
}
@@ -0,0 +1,29 @@
/*
* 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.scroll
/** Scroll event types that JS module RCTEventEmitter can understand */
public enum class ScrollEventType {
BEGIN_DRAG,
END_DRAG,
SCROLL,
MOMENTUM_BEGIN,
MOMENTUM_END;
public companion object {
@JvmStatic
public fun getJSEventName(type: ScrollEventType): String =
when (type) {
BEGIN_DRAG -> "topScrollBeginDrag"
END_DRAG -> "topScrollEndDrag"
SCROLL -> "topScroll"
MOMENTUM_BEGIN -> "topMomentumScrollBegin"
MOMENTUM_END -> "topMomentumScrollEnd"
}
}
}