diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java index 178007942d0..831e4555a59 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java @@ -65,7 +65,7 @@ public class ReactHorizontalScrollContainerView extends ReactViewGroup { ReactHorizontalScrollView parent = (ReactHorizontalScrollView) getParent(); // Fix the ScrollX position when using RTL language int offsetX = parent.getScrollX() + getWidth() - mCurrentWidth - parent.getWidth(); - parent.reactScrollTo(offsetX, parent.getScrollY()); + parent.scrollTo(offsetX, parent.getScrollY()); } } mCurrentWidth = getWidth(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java index c5f672479c2..666ae492e28 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java @@ -291,7 +291,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView pendingContentOffsetX != UNSET_CONTENT_OFFSET ? pendingContentOffsetX : getScrollX(); int scrollToY = pendingContentOffsetY != UNSET_CONTENT_OFFSET ? pendingContentOffsetY : getScrollY(); - reactScrollTo(scrollToX, scrollToY); + scrollTo(scrollToX, scrollToY); ReactScrollViewHelper.emitLayoutEvent(this); } @@ -1070,17 +1070,21 @@ public class ReactHorizontalScrollView extends HorizontalScrollView } /** - * Calls `reactScrollTo` and updates state. + * Calls `super.scrollTo` and updates state. * - *

`reactScrollTo` changes `contentOffset` and we need to keep `contentOffset` in sync between - * scroll view and state. Calling raw `reactScrollTo` doesn't update state. + *

`super.scrollTo` changes `contentOffset` and we need to keep `contentOffset` in sync between + * scroll view and state. + * + *

Note that while we can override scrollTo, we *cannot* override `smoothScrollTo` because it + * is final. See `reactSmoothScrollTo`. */ - public void reactScrollTo(int x, int y) { + @Override + public void scrollTo(int x, int y) { if (DEBUG_MODE) { - FLog.i(TAG, "reactScrollTo[%d] x %d y %d", getId(), x, y); + FLog.i(TAG, "scrollTo[%d] x %d y %d", getId(), x, y); } - scrollTo(x, y); + super.scrollTo(x, y); updateStateOnScroll(x, y); setPendingContentOffsets(x, y); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java index 9641fc11be9..38f025fbb60 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java @@ -193,7 +193,7 @@ public class ReactHorizontalScrollViewManager extends ViewGroupManager`reactScrollTo` changes `contentOffset` and we need to keep `contentOffset` in sync between * scroll view and state. Calling raw `reactScrollTo` doesn't update state. + * + *

Note that while we can override scrollTo, we *cannot* override `smoothScrollTo` because it + * is final. See `reactSmoothScrollTo`. */ - public void reactScrollTo(int x, int y) { - scrollTo(x, y); + @Override + public void scrollTo(int x, int y) { + super.scrollTo(x, y); updateStateOnScroll(x, y); setPendingContentOffsets(x, y); } @@ -926,7 +930,7 @@ public class ReactScrollView extends ScrollView int currentScrollY = getScrollY(); int maxScrollY = getMaxScrollY(); if (currentScrollY > maxScrollY) { - reactScrollTo(getScrollX(), maxScrollY); + scrollTo(getScrollX(), maxScrollY); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java index c9733b09697..f8add8ad32a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java @@ -206,7 +206,7 @@ public class ReactScrollViewManager extends ViewGroupManager if (data.mAnimated) { scrollView.reactSmoothScrollTo(data.mDestX, data.mDestY); } else { - scrollView.reactScrollTo(data.mDestX, data.mDestY); + scrollView.scrollTo(data.mDestX, data.mDestY); } } @@ -285,7 +285,7 @@ public class ReactScrollViewManager extends ViewGroupManager if (data.mAnimated) { scrollView.reactSmoothScrollTo(scrollView.getScrollX(), bottom); } else { - scrollView.reactScrollTo(scrollView.getScrollX(), bottom); + scrollView.scrollTo(scrollView.getScrollX(), bottom); } } @@ -310,9 +310,9 @@ public class ReactScrollViewManager extends ViewGroupManager if (value != null) { double x = value.hasKey("x") ? value.getDouble("x") : 0; double y = value.hasKey("y") ? value.getDouble("y") : 0; - view.reactScrollTo((int) PixelUtil.toPixelFromDIP(x), (int) PixelUtil.toPixelFromDIP(y)); + view.scrollTo((int) PixelUtil.toPixelFromDIP(x), (int) PixelUtil.toPixelFromDIP(y)); } else { - view.reactScrollTo(0, 0); + view.scrollTo(0, 0); } }