Back out "Track animations and flush them"

Summary:
Original commit changeset: b594d0e6e9b6

D20319824 introduced a problem in LayoutAnimations, which makes surfaced as the problem in T63911344. This diff reverts D20319824.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D20541918

fbshipit-source-id: ff72b839f57d39051122920a38b2632cbb5ec362
This commit is contained in:
Ramanpreet Nara
2020-03-19 20:46:32 -07:00
committed by Facebook GitHub Bot
parent 9c64bd5739
commit 950826f6b5
2 changed files with 1 additions and 43 deletions
@@ -366,8 +366,6 @@ public class NativeViewHierarchyManager {
UiThreadUtil.assertOnUiThread();
final Set<Integer> pendingDeletionTags = new HashSet<>();
mLayoutAnimator.cancelAnimationsForViewTag(tag);
final ViewGroup viewToManage = (ViewGroup) mTagsToViews.get(tag);
final ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(tag);
if (viewToManage == null) {
@@ -451,7 +449,6 @@ public class NativeViewHierarchyManager {
if (mLayoutAnimationEnabled && mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) {
pendingDeletionTags.add(tagToDelete);
mLayoutAnimator.deleteView(
tag,
viewToDestroy,
new LayoutAnimationListener() {
@Override
@@ -17,7 +17,6 @@ import androidx.annotation.Nullable;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.UiThreadUtil;
import java.util.ArrayList;
import javax.annotation.concurrent.NotThreadSafe;
/**
@@ -32,8 +31,6 @@ public class LayoutAnimationController {
private final AbstractLayoutAnimation mLayoutUpdateAnimation = new LayoutUpdateAnimation();
private final AbstractLayoutAnimation mLayoutDeleteAnimation = new LayoutDeleteAnimation();
private final SparseArray<LayoutHandlingAnimation> mLayoutHandlers = new SparseArray<>(0);
private final SparseArray<ArrayList<Animation>> mDeleteAnimationsByParentTag =
new SparseArray<>();
private boolean mShouldAnimateLayout;
private long mMaxAnimationDuration = -1;
@@ -116,7 +113,6 @@ public class LayoutAnimationController {
// Update an ongoing animation if possible, otherwise the layout update would be ignored as
// the existing animation would still animate to the old layout.
// Note the view is already inserted into the view hierarchy.
LayoutHandlingAnimation existingAnimation = mLayoutHandlers.get(reactTag);
if (existingAnimation != null) {
existingAnimation.onLayoutUpdate(x, y, width, height);
@@ -168,14 +164,11 @@ public class LayoutAnimationController {
* Animate a view deletion using the layout animation configuration supplied during
* initialization.
*
* @param parentReactTag tag of parent view of @param view. used to associate animation with for
* canceling
* @param view The view to animate.
* @param listener Called once the animation is finished, should be used to completely remove the
* view.
*/
public void deleteView(
final int parentReactTag, final View view, final LayoutAnimationListener listener) {
public void deleteView(final View view, final LayoutAnimationListener listener) {
UiThreadUtil.assertOnUiThread();
Animation animation =
@@ -195,10 +188,6 @@ public class LayoutAnimationController {
@Override
public void onAnimationEnd(Animation anim) {
ArrayList<Animation> animations = mDeleteAnimationsByParentTag.get(parentReactTag);
if (animations != null) {
animations.remove(anim);
}
listener.onAnimationEnd();
}
});
@@ -209,16 +198,7 @@ public class LayoutAnimationController {
mMaxAnimationDuration = animationDuration;
}
// Update our tracking list of delete animations
ArrayList<Animation> deleteAnimations = mDeleteAnimationsByParentTag.get(parentReactTag);
if (deleteAnimations == null) {
deleteAnimations = new ArrayList<>();
mDeleteAnimationsByParentTag.put(parentReactTag, deleteAnimations);
}
deleteAnimations.add(animation);
view.startAnimation(animation);
} else {
listener.onAnimationEnd();
}
@@ -245,23 +225,4 @@ public class LayoutAnimationController {
sCompletionHandler.postDelayed(mCompletionRunnable, delayMillis);
}
}
/**
* Animate a view deletion using the layout animation configuration supplied during
* initialization.
*
* @param viewTag tag of parent view that we're going to cancel all child animations.
*/
public void cancelAnimationsForViewTag(int viewTag) {
ArrayList<Animation> animations = mDeleteAnimationsByParentTag.get(viewTag);
if (animations == null) {
return;
}
for (int i = 0; i < animations.size(); i++) {
animations.get(i).cancel();
}
mDeleteAnimationsByParentTag.remove(viewTag);
}
}