mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate TrackingAnimatedNode.java to Kotlin (#45656)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45656 TrackingAnimatedNode.java -> TrackingAnimatedNode.kt changelog: [internal] internal Reviewed By: rshest Differential Revision: D60080041 fbshipit-source-id: b78070783cb24d4aed43827fdc866e6f9bb5a1bc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5b51ca0b92
commit
e86a5ee274
-50
@@ -1,50 +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.animated;
|
||||
|
||||
import com.facebook.react.bridge.JavaOnlyMap;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
|
||||
/* package */ class TrackingAnimatedNode extends AnimatedNode {
|
||||
|
||||
private final NativeAnimatedNodesManager mNativeAnimatedNodesManager;
|
||||
private final int mAnimationId;
|
||||
private final int mToValueNode;
|
||||
private final int mValueNode;
|
||||
private final JavaOnlyMap mAnimationConfig;
|
||||
|
||||
TrackingAnimatedNode(ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
|
||||
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
|
||||
mAnimationId = config.getInt("animationId");
|
||||
mToValueNode = config.getInt("toValue");
|
||||
mValueNode = config.getInt("value");
|
||||
mAnimationConfig = JavaOnlyMap.deepClone(config.getMap("animationConfig"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
AnimatedNode toValue = mNativeAnimatedNodesManager.getNodeById(mToValueNode);
|
||||
mAnimationConfig.putDouble("toValue", ((ValueAnimatedNode) toValue).getValue());
|
||||
mNativeAnimatedNodesManager.startAnimatingNode(
|
||||
mAnimationId, mValueNode, mAnimationConfig, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String prettyPrint() {
|
||||
return "TrackingAnimatedNode["
|
||||
+ tag
|
||||
+ "]: animationID: "
|
||||
+ mAnimationId
|
||||
+ " toValueNode: "
|
||||
+ mToValueNode
|
||||
+ " valueNode: "
|
||||
+ mValueNode
|
||||
+ " animationConfig: "
|
||||
+ mAnimationConfig;
|
||||
}
|
||||
}
|
||||
+36
@@ -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.getValue())
|
||||
} else {
|
||||
animationConfig.putNull("toValue")
|
||||
}
|
||||
nativeAnimatedNodesManager.startAnimatingNode(animationId, valueNode, animationConfig, null)
|
||||
}
|
||||
|
||||
public override fun prettyPrint(): String =
|
||||
"TrackingAnimatedNode[$tag]: animationID: $animationId toValueNode: $toValueNode " +
|
||||
"valueNode: $valueNode animationConfig: $animationConfig"
|
||||
}
|
||||
Reference in New Issue
Block a user