From bb5ba3d295f93aed824f4e5644f176afb69db285 Mon Sep 17 00:00:00 2001 From: Seth Kirby Date: Tue, 19 Jul 2016 13:54:44 -0700 Subject: [PATCH] Test perf impact of most straightforward fix for double detach. Summary: This is the most straightforward fix for the double detach issue. If a view is not attached, then addViewInLayout never propagates onAttach, and adding through attachViewToParent is a no op. We could hack something in to attach clipped FlatViewGroups in onClippingRect, but any other view that relies on onAttachedToWindow will have similar issues. Reviewed By: ahmedre Differential Revision: D3560565 --- .../main/java/com/facebook/react/flat/FlatViewGroup.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java index 77f422d7d..772709715 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatViewGroup.java @@ -877,18 +877,18 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper; // Now off the screen. Don't invalidate in this case, as the canvas should not be // redrawn unless new elements are coming onscreen. mClippedSubviews.put(view.getId(), view); - detachViewFromParent(view); + removeViewsInLayout(--index, 1); drawView.isViewGroupClipped = true; - index--; } } else { // Clipped, invisible. if (withinBounds(view, clippingRect)) { // Now on the screen. Invalidate as we have a new element to draw. - attachViewToParent( + addViewInLayout( view, index++, - ensureLayoutParams(view.getLayoutParams())); + ensureLayoutParams(view.getLayoutParams()), + true); mClippedSubviews.remove(view.getId()); drawView.isViewGroupClipped = false; needsInvalidate = true;