forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert TrackingAnimatedNode to Kotlin
Differential Revision: D60286293
- Loading branch information
1 parent
02e950d
commit 2210b33
Showing
2 changed files
with
36 additions
and
50 deletions.
There are no files selected for viewing
50 changes: 0 additions & 50 deletions
50
...t-native/ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...act-native/ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.animated | ||
|
||
import com.facebook.react.bridge.JavaOnlyMap | ||
import com.facebook.react.bridge.ReadableMap | ||
|
||
internal class TrackingAnimatedNode( | ||
config: ReadableMap, | ||
private val nativeAnimatedNodesManager: NativeAnimatedNodesManager | ||
) : AnimatedNode() { | ||
private val animationId: Int = config.getInt("animationId") | ||
private val toValueNode: Int = config.getInt("toValue") | ||
private val valueNode: Int = config.getInt("value") | ||
private val animationConfig: JavaOnlyMap = JavaOnlyMap.deepClone(config.getMap("animationConfig")) | ||
|
||
public override fun update() { | ||
val toValue = nativeAnimatedNodesManager.getNodeById(toValueNode) | ||
val valAnimatedNode = toValue as? ValueAnimatedNode | ||
if (valAnimatedNode != null) { | ||
animationConfig.putDouble("toValue", valAnimatedNode.value) | ||
} else { | ||
animationConfig.putNull("toValue") | ||
} | ||
nativeAnimatedNodesManager.startAnimatingNode(animationId, valueNode, animationConfig, null) | ||
} | ||
|
||
public override fun prettyPrint(): String = | ||
"TrackingAnimatedNode[$mTag]: animationID: $animationId toValueNode: $toValueNode " + | ||
"valueNode: $valueNode animationConfig: $animationConfig" | ||
} |