55 * LICENSE file in the root directory of this source tree.
66 */
77
8- package com .facebook .react .uimanager .common ;
8+ package com.facebook.react.uimanager.common
99
10- import static com .facebook .react .uimanager .common .UIManagerType .DEFAULT ;
11- import static com .facebook .react .uimanager .common .UIManagerType .FABRIC ;
10+ import com.facebook.react.uimanager.common.UIManagerType.DEFAULT
11+ import com.facebook.react.uimanager.common.UIManagerType.FABRIC
1212
13- import com .facebook .infer .annotation .Nullsafe ;
14-
15- @ Nullsafe (Nullsafe .Mode .LOCAL )
16- public class ViewUtil {
17-
18- public static final int NO_SURFACE_ID = -1 ;
13+ public object ViewUtil {
1914
15+ public const val NO_SURFACE_ID : Int = - 1
2016 /* *
2117 * Counter for uniquely identifying views. - % 2 === 0 means it is a Fabric tag. See
2218 * https://github.com/facebook/react/pull/12587
2319 *
24- * @param viewTag {@link int} tag of the view this is event is dispatched to
20+ * @param viewTag [ int] tag of the view this is event is dispatched to
2521 */
22+ @JvmStatic
2623 @UIManagerType
27- public static int getUIManagerType (int viewTag ) {
28- if (viewTag % 2 == 0 ) return FABRIC ;
29- return DEFAULT ;
30- }
24+ public fun getUIManagerType (viewTag : Int ): Int =
25+ if (viewTag % 2 == 0 ) {
26+ FABRIC
27+ } else {
28+ DEFAULT
29+ }
3130
3231 /* *
3332 * Version of getUIManagerType that uses both surfaceId and viewTag heuristics
3433 *
35- * @param viewTag {@link int} tag of the view this is event is dispatched to
36- * @param surfaceId {@link int} ID of the corresponding surface
34+ * @param viewTag [ int] tag of the view this is event is dispatched to
35+ * @param surfaceId [ int] ID of the corresponding surface
3736 */
37+ @JvmStatic
3838 @UIManagerType
39- public static int getUIManagerType (int viewTag , int surfaceId ) {
39+ public fun getUIManagerType (viewTag : Int , surfaceId : Int ): Int {
4040 // We have a contract that Fabric events *always* have a SurfaceId passed in, and non-Fabric
4141 // events NEVER have a SurfaceId passed in (the default/placeholder of -1 is passed in instead).
4242 //
@@ -47,21 +47,19 @@ public static int getUIManagerType(int viewTag, int surfaceId) {
4747 // non-Fabric UIManager, and we cannot use the ViewTag for inference since it's not controlled
4848 // by RN and is essentially a random number.
4949 // At some point it would be great to pass the SurfaceContext here instead.
50- @ UIManagerType int uiManagerType = (surfaceId == -1 ? DEFAULT : FABRIC );
51- if (uiManagerType == DEFAULT && !ViewUtil . isRootTag (viewTag )) {
50+ @UIManagerType val uiManagerType = if (surfaceId == - 1 ) DEFAULT else FABRIC
51+ if (uiManagerType == DEFAULT && ! isRootTag(viewTag)) {
5252 // TODO (T123064648): Some events for Fabric still didn't have the surfaceId set, so if it's
5353 // not a React RootView, double check if the tag belongs to Fabric.
54- if (viewTag % 2 == 0 ) return FABRIC ;
54+ if (viewTag % 2 == 0 ) {
55+ return FABRIC
56+ }
5557 }
56- return uiManagerType ;
58+ return uiManagerType
5759 }
58-
5960 /* *
60- * @param viewTag {@link int} react tag
61+ * @param viewTag [ int] react tag
6162 * @return if the react tag received by parameter is a RootTag or not.
6263 */
63- @ Deprecated
64- public static boolean isRootTag (int viewTag ) {
65- return viewTag % 10 == 1 ;
66- }
64+ @JvmStatic public fun isRootTag (viewTag : Int ): Boolean = viewTag % 10 == 1
6765}
0 commit comments