Skip to content

Commit bfb274c

Browse files
zeyapfacebook-github-bot
authored andcommitted
Convert NativeAnimatedNodesManager to kotlin
Summary: ## Changelog: [Android] [Changed] - Convert NativeAnimatedNodesManager to kotlin Reviewed By: alanleedev Differential Revision: D72657697 fbshipit-source-id: 36180d0906f6ef621b8b667442b61642f9ccc5d1
1 parent 02bf24b commit bfb274c

File tree

5 files changed

+813
-937
lines changed

5 files changed

+813
-937
lines changed

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

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ public abstract interface class com/facebook/react/ViewManagerOnDemandReactPacka
439439
public abstract fun getViewManagerNames (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/Collection;
440440
}
441441

442+
public abstract class com/facebook/react/animated/AnimatedNode {
443+
public fun <init> ()V
444+
}
445+
446+
public abstract interface class com/facebook/react/animated/AnimatedNodeValueListener {
447+
public abstract fun onValueUpdate (D)V
448+
}
449+
442450
public final class com/facebook/react/animated/NativeAnimatedModule : com/facebook/fbreact/specs/NativeAnimatedModuleSpec, com/facebook/react/bridge/LifecycleEventListener, com/facebook/react/bridge/UIManagerListener {
443451
public static final field ANIMATED_MODULE_DEBUG Z
444452
public static final field Companion Lcom/facebook/react/animated/NativeAnimatedModule$Companion;
@@ -485,32 +493,32 @@ public final class com/facebook/react/animated/NativeAnimatedModule : com/facebo
485493
public final class com/facebook/react/animated/NativeAnimatedModule$Companion {
486494
}
487495

488-
public class com/facebook/react/animated/NativeAnimatedNodesManager : com/facebook/react/uimanager/events/EventDispatcherListener {
496+
public final class com/facebook/react/animated/NativeAnimatedNodesManager : com/facebook/react/uimanager/events/EventDispatcherListener {
489497
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
490-
public fun addAnimatedEventToView (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;)V
491-
public fun connectAnimatedNodeToView (II)V
492-
public fun connectAnimatedNodes (II)V
493-
public fun createAnimatedNode (ILcom/facebook/react/bridge/ReadableMap;)V
494-
public fun disconnectAnimatedNodeFromView (II)V
495-
public fun disconnectAnimatedNodes (II)V
496-
public fun dropAnimatedNode (I)V
497-
public fun extractAnimatedNodeOffset (I)V
498-
public fun flattenAnimatedNodeOffset (I)V
499-
public fun getNodeById (I)Lcom/facebook/react/animated/AnimatedNode;
500-
public fun getValue (ILcom/facebook/react/bridge/Callback;)V
501-
public fun hasActiveAnimations ()Z
502-
public fun initializeEventListenerForUIManagerType (I)V
498+
public final fun addAnimatedEventToView (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;)V
499+
public final fun connectAnimatedNodeToView (II)V
500+
public final fun connectAnimatedNodes (II)V
501+
public final fun createAnimatedNode (ILcom/facebook/react/bridge/ReadableMap;)V
502+
public final fun disconnectAnimatedNodeFromView (II)V
503+
public final fun disconnectAnimatedNodes (II)V
504+
public final fun dropAnimatedNode (I)V
505+
public final fun extractAnimatedNodeOffset (I)V
506+
public final fun flattenAnimatedNodeOffset (I)V
507+
public final fun getNodeById (I)Lcom/facebook/react/animated/AnimatedNode;
508+
public final fun getValue (ILcom/facebook/react/bridge/Callback;)V
509+
public final fun hasActiveAnimations ()Z
510+
public final fun initializeEventListenerForUIManagerType (I)V
503511
public fun onEventDispatch (Lcom/facebook/react/uimanager/events/Event;)V
504-
public fun removeAnimatedEventFromView (ILjava/lang/String;I)V
505-
public fun restoreDefaultValues (I)V
506-
public fun runUpdates (J)V
507-
public fun setAnimatedNodeOffset (ID)V
508-
public fun setAnimatedNodeValue (ID)V
509-
public fun startAnimatingNode (IILcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;)V
510-
public fun startListeningToAnimatedNodeValue (ILcom/facebook/react/animated/AnimatedNodeValueListener;)V
511-
public fun stopAnimation (I)V
512-
public fun stopListeningToAnimatedNodeValue (I)V
513-
public fun updateAnimatedNodeConfig (ILcom/facebook/react/bridge/ReadableMap;)V
512+
public final fun removeAnimatedEventFromView (ILjava/lang/String;I)V
513+
public final fun restoreDefaultValues (I)V
514+
public final fun runUpdates (J)V
515+
public final fun setAnimatedNodeOffset (ID)V
516+
public final fun setAnimatedNodeValue (ID)V
517+
public final fun startAnimatingNode (IILcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;)V
518+
public final fun startListeningToAnimatedNodeValue (ILcom/facebook/react/animated/AnimatedNodeValueListener;)V
519+
public final fun stopAnimation (I)V
520+
public final fun stopListeningToAnimatedNodeValue (I)V
521+
public final fun updateAnimatedNodeConfig (ILcom/facebook/react/bridge/ReadableMap;)V
514522
}
515523

516524
public abstract interface class com/facebook/react/bridge/ActivityEventListener {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNode.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ package com.facebook.react.animated
1010
import java.util.ArrayList
1111

1212
/** Base class for all Animated.js library node types that can be created on the "native" side. */
13-
internal abstract class AnimatedNode {
13+
public abstract class AnimatedNode {
1414

15-
companion object {
16-
const val INITIAL_BFS_COLOR: Int = 0
17-
const val DEFAULT_ANIMATED_NODE_CHILD_COUNT: Int = 1
15+
internal companion object {
16+
internal const val INITIAL_BFS_COLOR: Int = 0
17+
internal const val DEFAULT_ANIMATED_NODE_CHILD_COUNT: Int = 1
1818
}
1919

2020
// TODO: T196787278 Reduce the visibility of these fields to package once we have
@@ -27,7 +27,7 @@ internal abstract class AnimatedNode {
2727
@JvmField internal var BFSColor: Int = INITIAL_BFS_COLOR
2828
@JvmField internal var tag: Int = -1
2929

30-
fun addChild(child: AnimatedNode): Unit {
30+
internal fun addChild(child: AnimatedNode): Unit {
3131
val currentChildren =
3232
children
3333
?: ArrayList<AnimatedNode>(DEFAULT_ANIMATED_NODE_CHILD_COUNT).also { children = it }
@@ -36,7 +36,7 @@ internal abstract class AnimatedNode {
3636
child.onAttachedToNode(this)
3737
}
3838

39-
fun removeChild(child: AnimatedNode): Unit {
39+
internal fun removeChild(child: AnimatedNode): Unit {
4040
val currentChildren = children ?: return
4141
child.onDetachedFromNode(this)
4242
currentChildren.remove(child)
@@ -48,24 +48,24 @@ internal abstract class AnimatedNode {
4848
* is important to also override [onDetachedFromNode] to clear that reference once current node
4949
* gets detached.
5050
*/
51-
open fun onAttachedToNode(parent: AnimatedNode): Unit = Unit
51+
internal open fun onAttachedToNode(parent: AnimatedNode): Unit = Unit
5252

5353
/** See [onAttachedToNode] */
54-
open fun onDetachedFromNode(parent: AnimatedNode): Unit = Unit
54+
internal open fun onDetachedFromNode(parent: AnimatedNode): Unit = Unit
5555

5656
/**
5757
* This method will be run on each node at most once every repetition of the animation loop. It
5858
* will be executed on a node only when all the node's parent has already been updated. Therefore
5959
* it can be used to calculate node's value.
6060
*/
61-
open fun update(): Unit = Unit
61+
internal open fun update(): Unit = Unit
6262

6363
/**
6464
* Pretty-printer for the AnimatedNode. Only called in production pre-crash for debug diagnostics.
6565
*/
66-
abstract fun prettyPrint(): String
66+
internal abstract fun prettyPrint(): String
6767

68-
fun prettyPrintWithChildren(): String {
68+
internal fun prettyPrintWithChildren(): String {
6969

7070
val currentChildren = children?.joinToString(" ")
7171
return prettyPrint() +

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNodeValueListener.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
package com.facebook.react.animated
99

1010
/** Interface used to listen to [ValueAnimatedNode] updates. */
11-
internal fun interface AnimatedNodeValueListener {
12-
fun onValueUpdate(value: Double)
11+
public fun interface AnimatedNodeValueListener {
12+
public fun onValueUpdate(value: Double)
1313
}

0 commit comments

Comments
 (0)