Skip to content

Commit 4e70c8d

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Migrate UIViewOperationQueue from Java to Kotlin (facebook#56942)
Summary: Pull Request resolved: facebook#56942 Migrate `UIViewOperationQueue` from Java to Kotlin as part of the ongoing Kotlin migration effort. This is a mechanical conversion of a deprecated, fully-stubbed legacy class with no functional changes. Changelog: [Android][Changed] - Migrate `UIViewOperationQueue` from Java to Kotlin Reviewed By: javache Differential Revision: D106080039
1 parent 707e366 commit 4e70c8d

3 files changed

Lines changed: 167 additions & 172 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4290,36 +4290,33 @@ public abstract interface class com/facebook/react/uimanager/UIManagerModule$Cus
42904290
public abstract fun resolveCustomEventName (Ljava/lang/String;)Ljava/lang/String;
42914291
}
42924292

4293-
public class com/facebook/react/uimanager/UIViewOperationQueue {
4293+
public final class com/facebook/react/uimanager/UIViewOperationQueue {
4294+
public static final field Companion Lcom/facebook/react/uimanager/UIViewOperationQueue$Companion;
42944295
public static final field DEFAULT_MIN_TIME_LEFT_IN_FRAME_FOR_NONBATCHED_OPERATION_MS I
42954296
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;I)V
4296-
public fun addRootView (ILandroid/view/View;)V
4297-
public fun dispatchViewUpdates (IJJ)V
4298-
public fun enqueueClearJSResponder ()V
4299-
public fun enqueueConfigureLayoutAnimation (Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;)V
4300-
public fun enqueueCreateView (Lcom/facebook/react/uimanager/ThemedReactContext;ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
4301-
public fun enqueueDispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
4302-
public fun enqueueDispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
4303-
public fun enqueueFindTargetForTouch (IFFLcom/facebook/react/bridge/Callback;)V
4304-
public fun enqueueManageChildren (I[I[Lcom/facebook/react/uimanager/ViewAtIndex;[I)V
4305-
public fun enqueueMeasure (ILcom/facebook/react/bridge/Callback;)V
4306-
public fun enqueueMeasureInWindow (ILcom/facebook/react/bridge/Callback;)V
4307-
public fun enqueueRemoveRootView (I)V
4308-
public fun enqueueSendAccessibilityEvent (II)V
4309-
public fun enqueueSetChildren (ILcom/facebook/react/bridge/ReadableArray;)V
4310-
public fun enqueueSetJSResponder (IIZ)V
4311-
public fun enqueueSetLayoutAnimationEnabled (Z)V
4312-
public fun enqueueUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
4313-
protected fun enqueueUIOperation (Lcom/facebook/react/uimanager/UIViewOperationQueue$UIOperation;)V
4314-
public fun enqueueUpdateExtraData (ILjava/lang/Object;)V
4315-
public fun enqueueUpdateInstanceHandle (IJ)V
4316-
public fun enqueueUpdateLayout (IIIIII)V
4317-
public fun enqueueUpdateLayout (IIIIIILcom/facebook/yoga/YogaDirection;)V
4318-
public fun enqueueUpdateProperties (ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
4319-
public fun getProfiledBatchPerfCounters ()Ljava/util/Map;
4320-
public fun isEmpty ()Z
4321-
public fun prependUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
4322-
public fun profileNextBatch ()V
4297+
public final fun addRootView (ILandroid/view/View;)V
4298+
public final fun dispatchViewUpdates (IJJ)V
4299+
public final fun enqueueClearJSResponder ()V
4300+
public final fun enqueueCreateView (Lcom/facebook/react/uimanager/ThemedReactContext;ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
4301+
public final fun enqueueDispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
4302+
public final fun enqueueDispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
4303+
public final fun enqueueFindTargetForTouch (IFFLcom/facebook/react/bridge/Callback;)V
4304+
public final fun enqueueMeasure (ILcom/facebook/react/bridge/Callback;)V
4305+
public final fun enqueueMeasureInWindow (ILcom/facebook/react/bridge/Callback;)V
4306+
public final fun enqueueRemoveRootView (I)V
4307+
public final fun enqueueSendAccessibilityEvent (II)V
4308+
public final fun enqueueSetJSResponder (IIZ)V
4309+
public final fun enqueueUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
4310+
public final fun enqueueUpdateExtraData (ILjava/lang/Object;)V
4311+
public final fun enqueueUpdateInstanceHandle (IJ)V
4312+
public final fun enqueueUpdateProperties (ILjava/lang/String;Lcom/facebook/react/uimanager/ReactStylesDiffMap;)V
4313+
public final fun getProfiledBatchPerfCounters ()Ljava/util/Map;
4314+
public final fun isEmpty ()Z
4315+
public final fun prependUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
4316+
public final fun profileNextBatch ()V
4317+
}
4318+
4319+
public final class com/facebook/react/uimanager/UIViewOperationQueue$Companion {
43234320
}
43244321

43254322
public abstract interface class com/facebook/react/uimanager/UIViewOperationQueue$UIOperation {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java

Lines changed: 0 additions & 144 deletions
This file was deleted.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.uimanager
9+
10+
import android.view.View
11+
import com.facebook.react.bridge.Callback
12+
import com.facebook.react.bridge.ReactApplicationContext
13+
import com.facebook.react.bridge.ReadableArray
14+
import com.facebook.react.common.annotations.internal.LegacyArchitecture
15+
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
16+
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
17+
18+
/**
19+
* This class acts as a buffer for command executed on [NativeViewHierarchyManager]. It expose
20+
* similar methods as mentioned classes but instead of executing commands immediately it enqueues
21+
* those operations in a queue that is then flushed from [UIManagerModule] once JS batch of ui
22+
* operations is finished. This is to make sure that we execute all the JS operation coming from a
23+
* single batch a single loop of the main (UI) android looper.
24+
*
25+
* @deprecated This class is stubbed out and will be removed in a future release.
26+
*
27+
* TODO(7135923): Pooling of operation objects TODO(5694019): Consider a better data structure for
28+
* operations queue to save on allocations
29+
*/
30+
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
31+
@Deprecated("This class is part of Legacy Architecture and will be removed in a future release")
32+
public class UIViewOperationQueue(
33+
reactContext: ReactApplicationContext,
34+
minTimeLeftInFrameForNonBatchedOperationMs: Int,
35+
) {
36+
37+
/** A mutation or animation operation on the view hierarchy. */
38+
public interface UIOperation {
39+
/** Executes the UI operation. */
40+
public fun execute()
41+
}
42+
43+
public companion object {
44+
/** Default minimum time left in frame for non-batched operations, in milliseconds. */
45+
public const val DEFAULT_MIN_TIME_LEFT_IN_FRAME_FOR_NONBATCHED_OPERATION_MS: Int = 8
46+
47+
init {
48+
LegacyArchitectureLogger.assertLegacyArchitecture(
49+
"UIViewOperationQueue",
50+
LegacyArchitectureLogLevel.ERROR,
51+
)
52+
}
53+
}
54+
55+
/** Profiles the next batch of UI operations. */
56+
public fun profileNextBatch() {}
57+
58+
/** Returns profiled batch performance counters. */
59+
public fun getProfiledBatchPerfCounters(): Map<String, Long> = HashMap()
60+
61+
/** Returns whether the operation queue is empty. */
62+
public fun isEmpty(): Boolean = true
63+
64+
/** Adds a root view with the given tag. */
65+
public fun addRootView(tag: Int, rootView: View) {}
66+
67+
/** Enqueues a UI operation for execution. */
68+
protected fun enqueueUIOperation(operation: UIOperation) {}
69+
70+
/** Enqueues removal of a root view with the given tag. */
71+
public fun enqueueRemoveRootView(rootViewTag: Int) {}
72+
73+
/** Enqueues setting the JS responder for the given tag. */
74+
public fun enqueueSetJSResponder(tag: Int, initialTag: Int, blockNativeResponder: Boolean) {}
75+
76+
/** Enqueues clearing the JS responder. */
77+
public fun enqueueClearJSResponder() {}
78+
79+
/**
80+
* Enqueues dispatching a command with an integer command ID.
81+
*
82+
* @deprecated Use [enqueueDispatchCommand] with a String commandId instead.
83+
*/
84+
@Deprecated("Use enqueueDispatchCommand with a String commandId instead")
85+
public fun enqueueDispatchCommand(reactTag: Int, commandId: Int, commandArgs: ReadableArray?) {}
86+
87+
/** Enqueues dispatching a command with a string command ID. */
88+
public fun enqueueDispatchCommand(
89+
reactTag: Int,
90+
commandId: String,
91+
commandArgs: ReadableArray?,
92+
) {}
93+
94+
/** Enqueues updating extra data for the given react tag. */
95+
public fun enqueueUpdateExtraData(reactTag: Int, extraData: Any?) {}
96+
97+
/** Enqueues creating a view with the given properties. */
98+
public fun enqueueCreateView(
99+
themedContext: ThemedReactContext,
100+
viewReactTag: Int,
101+
viewClassName: String,
102+
initialProps: ReactStylesDiffMap?,
103+
) {}
104+
105+
/** Enqueues updating the instance handle for the given react tag. */
106+
public fun enqueueUpdateInstanceHandle(reactTag: Int, instanceHandle: Long) {}
107+
108+
/** Enqueues updating properties for the given react tag. */
109+
public fun enqueueUpdateProperties(reactTag: Int, className: String, props: ReactStylesDiffMap) {}
110+
111+
/** Enqueues measuring the view with the given react tag. */
112+
public fun enqueueMeasure(reactTag: Int, callback: Callback) {}
113+
114+
/** Enqueues measuring the view in window coordinates with the given react tag. */
115+
public fun enqueueMeasureInWindow(reactTag: Int, callback: Callback) {}
116+
117+
/** Enqueues finding the target view for a touch at the given coordinates. */
118+
public fun enqueueFindTargetForTouch(
119+
reactTag: Int,
120+
targetX: Float,
121+
targetY: Float,
122+
callback: Callback,
123+
) {}
124+
125+
/** Enqueues sending an accessibility event for the given tag. */
126+
public fun enqueueSendAccessibilityEvent(tag: Int, eventType: Int) {}
127+
128+
/** Enqueues a UI block for execution. */
129+
@Suppress("DEPRECATION") public fun enqueueUIBlock(block: UIBlock) {}
130+
131+
/** Prepends a UI block for execution before existing queued operations. */
132+
@Suppress("DEPRECATION") public fun prependUIBlock(block: UIBlock) {}
133+
134+
/** Dispatches view updates for the given batch. */
135+
public fun dispatchViewUpdates(batchId: Int, commitStartTime: Long, layoutTime: Long) {}
136+
137+
/** Resumes the frame callback. */
138+
internal fun resumeFrameCallback() {}
139+
140+
/** Pauses the frame callback. */
141+
internal fun pauseFrameCallback() {}
142+
}

0 commit comments

Comments
 (0)