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.
Migrate TrackingAnimatedNode.java to Kotlin (facebook#45656)
Summary: Pull Request resolved: facebook#45656 TrackingAnimatedNode.java -> TrackingAnimatedNode.kt changelog: [internal] internal Differential Revision: D60080041
- Loading branch information
1 parent
d65c431
commit 3550b25
Showing
2 changed files
with
48 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.
48 changes: 48 additions & 0 deletions
48
...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,48 @@ | ||
/* | ||
* 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.JSApplicationCausedNativeException | ||
import com.facebook.react.bridge.JavaOnlyMap | ||
import com.facebook.react.bridge.ReadableMap | ||
|
||
internal open class TrackingAnimatedNode : AnimatedNode { | ||
|
||
private val mNativeAnimatedNodesManager: NativeAnimatedNodesManager | ||
private val mAnimationId: Int | ||
private val mToValueNode: Int | ||
private val mValueNode: Int | ||
private val mAnimationConfig: JavaOnlyMap | ||
|
||
public constructor( | ||
config: ReadableMap, | ||
nativeAnimatedNodesManager: NativeAnimatedNodesManager | ||
) : super() { | ||
mNativeAnimatedNodesManager = nativeAnimatedNodesManager | ||
mAnimationId = config.getInt("animationId") | ||
mToValueNode = config.getInt("toValue") | ||
mValueNode = config.getInt("value") | ||
mAnimationConfig = JavaOnlyMap.deepClone(config.getMap("animationConfig")) | ||
} | ||
|
||
override public fun update(): Unit { | ||
val toValue = mNativeAnimatedNodesManager.getNodeById(mToValueNode) | ||
if (toValue is ValueAnimatedNode) { | ||
mAnimationConfig.putDouble("toValue", toValue.mValue) | ||
mNativeAnimatedNodesManager.startAnimatingNode( | ||
mAnimationId, mValueNode, mAnimationConfig, null) | ||
} else { | ||
throw JSApplicationCausedNativeException( | ||
"Illegal node ID set as an input for TrackingAnimated node") | ||
} | ||
} | ||
|
||
override public fun prettyPrint(): String { | ||
return "TrackingAnimatedNode[$mTag]: animationID: $mAnimationId toValueNode: $mToValueNode valueNode: $mValueNode animationConfig: $mAnimationConfig" | ||
} | ||
} |