Files
react-native/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNode.java
T
Oleksandr Melnykov 6c0f73b322 Format Java code in xplat/js/react-native-github
Summary:
This diff formats the Java class files inside xplat/js/react-native-github. Since google-java-format was enabled in D16071401 we want to codemode the existing code so that users don't have to deal with formatter lint noise at diff-time.

```arc f --paths-cmd 'hg files -I "**/*.java"'```

drop-conflicts

Reviewed By: cpojer

Differential Revision: D16071725

fbshipit-source-id: fc6e3852e45742c109f0c5ac4065d64201c74204
2019-07-02 04:16:46 -07:00

60 lines
2.0 KiB
Java

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>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.infer.annotation.Assertions;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
/** Base class for all Animated.js library node types that can be created on the "native" side. */
/*package*/ abstract class AnimatedNode {
public static final int INITIAL_BFS_COLOR = 0;
private static final int DEFAULT_ANIMATED_NODE_CHILD_COUNT = 1;
/*package*/ @Nullable List<AnimatedNode> mChildren; /* lazy-initialized when a child is added */
/*package*/ int mActiveIncomingNodes = 0;
/*package*/ int mBFSColor = INITIAL_BFS_COLOR;
/*package*/ int mTag = -1;
public final void addChild(AnimatedNode child) {
if (mChildren == null) {
mChildren = new ArrayList<>(DEFAULT_ANIMATED_NODE_CHILD_COUNT);
}
Assertions.assertNotNull(mChildren).add(child);
child.onAttachedToNode(this);
}
public final void removeChild(AnimatedNode child) {
if (mChildren == null) {
return;
}
child.onDetachedFromNode(this);
mChildren.remove(child);
}
/**
* Subclasses may want to override this method in order to store a reference to the parent of a
* given node that can then be used to calculate current node's value in {@link #update}. In that
* case it is important to also override {@link #onDetachedFromNode} to clear that reference once
* current node gets detached.
*/
public void onAttachedToNode(AnimatedNode parent) {}
/** See {@link #onAttachedToNode} */
public void onDetachedFromNode(AnimatedNode parent) {}
/**
* This method will be run on each node at most once every repetition of the animation loop. It
* will be executed on a node only when all the node's parent has already been updated. Therefore
* it can be used to calculate node's value.
*/
public void update() {}
}