Skip to content

Commit

Permalink
Migrate TrackingAnimatedNode.java to Kotlin
Browse files Browse the repository at this point in the history
Summary:
TrackingAnimatedNode.java -> TrackingAnimatedNode.kt

changelog: [internal] internal

Differential Revision: D60080041
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Jul 28, 2024
1 parent 1ffe248 commit a5ec7c7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 50 deletions.

This file was deleted.

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.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"
}

0 comments on commit a5ec7c7

Please sign in to comment.