Allow for customization of the RootViewManager
Summary: Groups encountered a pretty major crash where, in many cases, we would find that DrawCommands and Views were out of sync. This turns out to be due to the fact that when we drop views from the root view, we remove each child using removeChildAt (which ultimately causes an invalidate and redraw). If this happens for a FlatViewGroup, this causes issues where the Views are all removed, but there are some DrawCommands (potentially DrawViews) that aren't removed, hence them going out of sync. Reviewed By: astreet Differential Revision: D3473916
This commit is contained in:
parent
f223335dae
commit
f602640e5c
|
@ -32,7 +32,7 @@ import com.facebook.react.uimanager.ViewManagerRegistry;
|
|||
implements ViewResolver {
|
||||
|
||||
/* package */ FlatNativeViewHierarchyManager(ViewManagerRegistry viewManagers) {
|
||||
super(viewManagers);
|
||||
super(viewManagers, new FlatRootViewManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.react.flat;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.facebook.react.uimanager.RootViewManager;
|
||||
|
||||
/* package */ class FlatRootViewManager extends RootViewManager {
|
||||
|
||||
@Override
|
||||
public void removeAllViews(ViewGroup parent) {
|
||||
parent.removeAllViewsInLayout();
|
||||
}
|
||||
}
|
|
@ -451,6 +451,16 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper;
|
|||
removeDetachedView(view, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllViewsInLayout() {
|
||||
// whenever we want to remove all views in a layout, we also want to remove all the
|
||||
// DrawCommands, otherwise, we can have a mismatch between the DrawView DrawCommands
|
||||
// and the Views to draw (note that because removeAllViewsInLayout doesn't call invalidate,
|
||||
// we don't actually need to modify mDrawCommands, but we do it just in case).
|
||||
mDrawCommands = DrawCommand.EMPTY_ARRAY;
|
||||
super.removeAllViewsInLayout();
|
||||
}
|
||||
|
||||
/* package */ void mountAttachDetachListeners(AttachDetachListener[] listeners) {
|
||||
if (mIsAttached) {
|
||||
// Ordering of the following 2 statements is very important. While logically it makes sense to
|
||||
|
|
|
@ -23,4 +23,9 @@ abstract class FlatViewManager extends ViewGroupManager<FlatViewGroup> {
|
|||
public void setBackgroundColor(FlatViewGroup view, int backgroundColor) {
|
||||
// suppress
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllViews(FlatViewGroup parent) {
|
||||
parent.removeAllViewsInLayout();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue