mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix layout animation crash
Summary: As of D14529038, LayoutAnimations can sometimes throw an exception due to the view being null. This can happen when elements are removed/added and is not fixable in product code. This is a temporary fix - the root cause for this issue will be fixed soon. Reviewed By: lunaleaps Differential Revision: D15428791 fbshipit-source-id: 41200e572ed7d5d470754792c5576a0ea23fe946
This commit is contained in:
committed by
Facebook Github Bot
parent
5127ac5c2a
commit
9fb31d1538
+1
-1
@@ -444,7 +444,7 @@ public class NativeViewHierarchyManager {
|
||||
arrayContains(tagsToDelete, viewToRemove.getId())) {
|
||||
// The view will be removed and dropped by the 'delete' layout animation
|
||||
// instead, so do nothing
|
||||
} else {
|
||||
} else if (viewToManage != null) {
|
||||
viewManager.removeViewAt(viewToManage, normalizedIndexToRemove);
|
||||
}
|
||||
|
||||
|
||||
+8
-4
@@ -82,10 +82,14 @@ public class LayoutAnimationController {
|
||||
}
|
||||
|
||||
public boolean shouldAnimateLayout(View viewToAnimate) {
|
||||
// if view parent is null, skip animation: view have been clipped, we don't want animation to
|
||||
// resume when view is re-attached to parent, which is the standard android animation behavior.
|
||||
// If there's a layout handling animation going on, it should be animated nonetheless since the
|
||||
// ongoing animation needs to be updated.
|
||||
// if view is null or the view parent is null, skip animation: view have been clipped,
|
||||
// we don't want animation to resume when view is re-attached to parent, which is the
|
||||
// standard android animation behavior. If there's a layout handling animation going on,
|
||||
// it should be animated nonetheless since the ongoing animation needs to be updated.
|
||||
|
||||
if (viewToAnimate == null) {
|
||||
return false;
|
||||
}
|
||||
return (mShouldAnimateLayout && viewToAnimate.getParent() != null)
|
||||
|| mLayoutHandlers.get(viewToAnimate.getId()) != null;
|
||||
}
|
||||
|
||||
@@ -465,7 +465,9 @@ public class ReactViewGroup extends ViewGroup implements
|
||||
mDrawingOrderHelper.handleRemoveView(getChildAt(index));
|
||||
setChildrenDrawingOrderEnabled(mDrawingOrderHelper.shouldEnableCustomDrawingOrder());
|
||||
|
||||
super.removeViewAt(index);
|
||||
if (getChildAt(index) != null) {
|
||||
super.removeViewAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user