Unbreak nodes that use ScrollViews

Reviewed By: foghina

Differential Revision: D3870895

fbshipit-source-id: e01130f19cca96ae1bcd0b8040e78552727fd6dc
This commit is contained in:
Andy Street 2016-09-15 11:01:15 -07:00 committed by Facebook Github Bot 6
parent 6f42603d0e
commit 5c3f9547c6
2 changed files with 20 additions and 2 deletions

View File

@ -10,6 +10,7 @@ android_library(
react_native_target('java/com/facebook/react/touch:touch'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),

View File

@ -20,7 +20,9 @@ import android.view.View;
import android.widget.OverScroller;
import android.widget.ScrollView;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSApplicationCausedNativeException;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.ReactConstants;
@ -29,6 +31,7 @@ import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.NativeGestureUtil;
import com.facebook.react.uimanager.ReactClippingViewGroup;
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.views.view.ReactViewGroup;
import com.facebook.react.views.view.ReactViewManager;
@ -47,6 +50,7 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou
private static Field sScrollerField;
private static boolean sTriedToGetScrollerField = false;
private static boolean sHasWarnedAboutStickyHeaders = false;
private final OnScrollDispatchHelper mOnScrollDispatchHelper = new OnScrollDispatchHelper();
private final OverScroller mScroller;
@ -63,7 +67,7 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou
private @Nullable Drawable mEndBackground;
private int mEndFillColor = Color.TRANSPARENT;
private @Nullable int[] mStickyHeaderIndices;
private ReactViewManager mViewManager;
private ViewGroupManager mViewManager;
private final ReactViewGroup.ChildDrawingOrderDelegate mContentDrawingOrderDelegate =
new ReactViewGroup.ChildDrawingOrderDelegate() {
@ -81,7 +85,7 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou
super(context);
UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
mViewManager = (ReactViewManager) uiManager.getUIImplementation().getViewManager(ReactViewManager.REACT_CLASS);
mViewManager = (ViewGroupManager) uiManager.getUIImplementation().getViewManager(ReactViewManager.REACT_CLASS);
mFpsListener = fpsListener;
@ -350,6 +354,19 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou
View previousHeader = null;
View currentHeader = null;
View nextHeader = null;
View firstChild = getChildAt(0);
if (!(firstChild instanceof ReactViewGroup)) {
if (!sHasWarnedAboutStickyHeaders) {
FLog.w(
ReactConstants.TAG,
"'stickyHeaderIndices' isn't a supported prop type for this UIImplementation (nodes). " +
"It'd be awesome if you could help us support it by sending a diff or PR :)");
sHasWarnedAboutStickyHeaders = true;
}
return;
}
ReactViewGroup contentView = (ReactViewGroup) getChildAt(0);
if (contentView == null) {
return;