From 950826f6b53a2cf200615fde5b65443b57537e07 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 19 Mar 2020 20:46:32 -0700 Subject: [PATCH] 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 --- .../uimanager/NativeViewHierarchyManager.java | 3 -- .../LayoutAnimationController.java | 41 +------------------ 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index 6a8f27025e9..f89215ece64 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -366,8 +366,6 @@ public class NativeViewHierarchyManager { UiThreadUtil.assertOnUiThread(); final Set 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 diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationController.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationController.java index 148b9a4c8e7..046d757e2af 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationController.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/layoutanimation/LayoutAnimationController.java @@ -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 mLayoutHandlers = new SparseArray<>(0); - private final SparseArray> 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 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 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 animations = mDeleteAnimationsByParentTag.get(viewTag); - if (animations == null) { - return; - } - - for (int i = 0; i < animations.size(); i++) { - animations.get(i).cancel(); - } - - mDeleteAnimationsByParentTag.remove(viewTag); - } }