Permalink
Browse files

BREAKING: Move RecyclerViewBackedScrollView out of open source

Summary: `RecyclerViewBackedScrollView` was added a long time ago to work around the scroll-back-when-data-is-added bug, but that has now been fixed directly in the `ScrollView` (`ReactScrollView.java`) in open source and internally.

Reviewed By: astreet

Differential Revision: D4482105

fbshipit-source-id: 208f21f00045d5c5a83b74ad69b3db6fa63391d7
  • Loading branch information...
mkonicek authored and facebook-github-bot committed Feb 2, 2017
1 parent 3ee3d2b commit 6ec5654e7a26b856dbe26b2ba74c15ec258f065e
@@ -1,189 +0,0 @@
-/**
- * Copyright 2004-present Facebook. All Rights Reserved.
- *
- * @providesModule RecyclerViewBackedScrollView
- */
-'use strict';
-
-var React = require('React');
-var ScrollResponder = require('ScrollResponder');
-var ScrollView = require('ScrollView');
-var View = require('View');
-var StyleSheet = require('StyleSheet');
-
-var requireNativeComponent = require('requireNativeComponent');
-
-var INNERVIEW = 'InnerView';
-
-/**
- * RecyclerViewBackedScrollView is DEPRECATED and will be removed from
- * React Native.
- * Please use a `ListView` which has `removeClippedSubviews` enabled by
- * default so that rows that are out of sight are automatically
- * detached from the view hierarchy.
- *
- * Wrapper around Android native recycler view.
- *
- * It simply renders rows passed as children in a separate recycler view cells
- * similarly to how `ScrollView` is doing it. Thanks to the fact that it uses
- * native `RecyclerView` though, rows that are out of sight are going to be
- * automatically detached (similarly on how this would work with
- * `removeClippedSubviews = true` on a `ScrollView.js`).
- *
- * CAUTION: This is an experimental component and should only be used together
- * with javascript implementation of list view (see ListView.js). In order to
- * use it pass this component as `renderScrollComponent` to the list view. For
- * now only horizontal scrolling is supported.
- *
- * Example:
- *
- * ```
- * getInitialState: function() {
- * var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
- * return {
- * dataSource: ds.cloneWithRows(['row 1', 'row 2']),
- * };
- * },
- *
- * render: function() {
- * return (
- * <ListView
- * dataSource={this.state.dataSource}
- * renderRow={rowData => <Text>{rowData}</Text>}
- * renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
- * />
- * );
- * },
- * ```
- */
-var RecyclerViewBackedScrollView = React.createClass({
-
- propTypes: {
- ...ScrollView.propTypes,
- },
-
- mixins: [ScrollResponder.Mixin],
-
- componentWillMount: function() {
- console.warn(
- 'RecyclerViewBackedScrollView is DEPRECATED and will be removed from React Native. ' +
- 'Please use a ListView which has removeClippedSubviews enabled by default so that ' +
- 'rows that are out of sight are automatically detached from the view hierarchy.')
- },
-
- getInitialState: function() {
- return this.scrollResponderMixinGetInitialState();
- },
-
- getScrollResponder: function() {
- return this;
- },
-
- setNativeProps: function(props: Object) {
- this.refs[INNERVIEW].setNativeProps(props);
- },
-
- _handleContentSizeChange: function(event) {
- var {width, height} = event.nativeEvent;
- this.props.onContentSizeChange(width, height);
- },
-
- /**
- * A helper function to scroll to a specific point in the scrollview.
- * This is currently used to help focus on child textviews, but can also
- * be used to quickly scroll to any element we want to focus. Syntax:
- *
- * scrollResponderScrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
- *
- * Note: The weird argument signature is due to the fact that, for historical reasons,
- * the function also accepts separate arguments as as alternative to the options object.
- * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
- */
- scrollTo: function(
- y?: number | { x?: number, y?: number, animated?: boolean },
- x?: number,
- animated?: boolean
- ) {
- if (typeof y === 'number') {
- console.warn('`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, animated: true})` instead.');
- } else {
- ({x, y, animated} = y || {});
- }
- this.getScrollResponder().scrollResponderScrollTo({x: x || 0, y: y || 0, animated: animated !== false});
- },
-
- render: function() {
- var recyclerProps = {
- ...this.props,
- onTouchStart: this.scrollResponderHandleTouchStart,
- onTouchMove: this.scrollResponderHandleTouchMove,
- onTouchEnd: this.scrollResponderHandleTouchEnd,
- onScrollBeginDrag: this.scrollResponderHandleScrollBeginDrag,
- onScrollEndDrag: this.scrollResponderHandleScrollEndDrag,
- onMomentumScrollBegin: this.scrollResponderHandleMomentumScrollBegin,
- onMomentumScrollEnd: this.scrollResponderHandleMomentumScrollEnd,
- onStartShouldSetResponder: this.scrollResponderHandleStartShouldSetResponder,
- onStartShouldSetResponderCapture: this.scrollResponderHandleStartShouldSetResponderCapture,
- onScrollShouldSetResponder: this.scrollResponderHandleScrollShouldSetResponder,
- onResponderGrant: this.scrollResponderHandleResponderGrant,
- onResponderRelease: this.scrollResponderHandleResponderRelease,
- onResponderReject: this.scrollResponderHandleResponderReject,
- onScroll: this.scrollResponderHandleScroll,
- ref: INNERVIEW,
- };
-
- if (this.props.onContentSizeChange) {
- recyclerProps.onContentSizeChange = this._handleContentSizeChange;
- }
-
- var wrappedChildren = React.Children.map(this.props.children, (child) => {
- if (!child) {
- return null;
- }
- return (
- <View
- collapsable={false}
- style={styles.absolute}>
- {child}
- </View>
- );
- });
-
- const refreshControl = this.props.refreshControl;
- if (refreshControl) {
- // Wrap the NativeAndroidRecyclerView with a AndroidSwipeRefreshLayout.
- return React.cloneElement(
- refreshControl,
- {style: [styles.base, this.props.style]},
- <NativeAndroidRecyclerView {...recyclerProps} style={styles.base}>
- {wrappedChildren}
- </NativeAndroidRecyclerView>
- );
- }
-
- return (
- <NativeAndroidRecyclerView {...recyclerProps} style={[styles.base, this.props.style]}>
- {wrappedChildren}
- </NativeAndroidRecyclerView>
- );
- },
-});
-
-var styles = StyleSheet.create({
- absolute: {
- position: 'absolute',
- top: 0,
- left: 0,
- right: 0,
- },
- base: {
- flex: 1,
- },
-});
-
-var NativeAndroidRecyclerView = requireNativeComponent(
- 'AndroidRecyclerViewBackedScrollView',
- RecyclerViewBackedScrollView
-);
-
-module.exports = RecyclerViewBackedScrollView;
@@ -1,8 +0,0 @@
-/**
- * Copyright 2004-present Facebook. All Rights Reserved.
- *
- * @providesModule RecyclerViewBackedScrollView
- */
-'use strict';
-
-module.exports = require('ScrollView');
@@ -50,7 +50,6 @@ const ReactNative = {
get Slider() { return require('Slider'); },
get SnapshotViewIOS() { return require('SnapshotViewIOS'); },
get Switch() { return require('Switch'); },
- get RecyclerViewBackedScrollView() { return require('RecyclerViewBackedScrollView'); },
get RefreshControl() { return require('RefreshControl'); },
get StatusBar() { return require('StatusBar'); },
get SwipeableListView() { return require('SwipeableListView'); },
@@ -1,6 +1,7 @@
include_defs('//ReactAndroid/DEFS')
deps = [
+ '//java/com/facebook/fbreact/views/recyclerview:recyclerview',
react_native_dep('third-party/android/support/v4:lib-support-v4'),
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_dep('third-party/java/junit:junit'),
@@ -19,7 +20,6 @@ deps = [
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
react_native_target('java/com/facebook/react/views/picker:picker'),
react_native_target('java/com/facebook/react/views/progressbar:progressbar'),
- react_native_target('java/com/facebook/react/views/recyclerview:recyclerview'),
react_native_target('java/com/facebook/react/views/scroll:scroll'),
react_native_target('java/com/facebook/react/views/slider:slider'),
react_native_target('java/com/facebook/react/views/swiperefresh:swiperefresh'),
@@ -4,6 +4,7 @@ android_library(
name = 'shell',
srcs = glob(['**/*.java']),
deps = [
+ '//java/com/facebook/fbreact/views/recyclerview:recyclerview',
react_native_dep('libraries/fresco/fresco-react-native:imagepipeline'),
react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'),
react_native_dep('third-party/android/support/v4:lib-support-v4'),
@@ -45,7 +46,6 @@ android_library(
react_native_target('java/com/facebook/react/views/modal:modal'),
react_native_target('java/com/facebook/react/views/picker:picker'),
react_native_target('java/com/facebook/react/views/progressbar:progressbar'),
- react_native_target('java/com/facebook/react/views/recyclerview:recyclerview'),
react_native_target('java/com/facebook/react/views/scroll:scroll'),
react_native_target('java/com/facebook/react/views/slider:slider'),
react_native_target('java/com/facebook/react/views/swiperefresh:swiperefresh'),
@@ -67,7 +67,6 @@
import com.facebook.react.views.picker.ReactDialogPickerManager;
import com.facebook.react.views.picker.ReactDropdownPickerManager;
import com.facebook.react.views.progressbar.ReactProgressBarViewManager;
-import com.facebook.react.views.recyclerview.RecyclerViewBackedScrollViewManager;
import com.facebook.react.views.scroll.ReactHorizontalScrollViewManager;
import com.facebook.react.views.scroll.ReactScrollViewManager;
import com.facebook.react.views.slider.ReactSliderManager;
@@ -275,7 +274,6 @@ public NativeModule get() {
viewManagers.add(new ReactViewPagerManager());
viewManagers.add(new ReactVirtualTextViewManager());
viewManagers.add(new ReactWebViewManager());
- viewManagers.add(new RecyclerViewBackedScrollViewManager());
viewManagers.add(new SwipeRefreshLayoutManager());
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(reactContext);
@@ -1,23 +0,0 @@
-include_defs('//ReactAndroid/DEFS')
-
-android_library(
- name = 'recyclerview',
- srcs = glob(['**/*.java']),
- deps = [
- react_native_dep('third-party/android/support/v4:lib-support-v4'),
- react_native_dep('third-party/android/support/v7/recyclerview:recyclerview'),
- react_native_dep('third-party/java/infer-annotations:infer-annotations'),
- react_native_dep('third-party/java/jsr-305:jsr-305'),
- react_native_target('java/com/facebook/react/bridge:bridge'),
- react_native_target('java/com/facebook/react/common:common'),
- 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_target('java/com/facebook/react/views/scroll:scroll'),
- react_native_target('java/com/facebook/react/views/view:view'),
- ],
- visibility = [
- 'PUBLIC',
- ],
-)
-
@@ -1,71 +0,0 @@
-// Copyright 2004-present Facebook. All Rights Reserved.
-
-package com.facebook.react.views.recyclerview;
-
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.SimpleItemAnimator;
-
-/**
- * Implementation of {@link RecyclerView.ItemAnimator} that disables all default animations.
- */
-/*package*/ class NotAnimatedItemAnimator extends SimpleItemAnimator {
-
- @Override
- public void runPendingAnimations() {
- // nothing
- }
-
- @Override
- public boolean animateRemove(RecyclerView.ViewHolder holder) {
- dispatchRemoveStarting(holder);
- dispatchRemoveFinished(holder);
- return true;
- }
-
- @Override
- public boolean animateAdd(RecyclerView.ViewHolder holder) {
- dispatchAddStarting(holder);
- dispatchAddFinished(holder);
- return true;
- }
-
- @Override
- public boolean animateMove(
- RecyclerView.ViewHolder holder,
- int fromX,
- int fromY,
- int toX,
- int toY) {
- dispatchMoveStarting(holder);
- dispatchMoveFinished(holder);
- return true;
- }
-
- @Override
- public boolean animateChange(
- RecyclerView.ViewHolder oldHolder,
- RecyclerView.ViewHolder newHolder,
- int fromLeft,
- int fromTop,
- int toLeft,
- int toTop) {
- dispatchChangeStarting(oldHolder, true);
- dispatchChangeFinished(oldHolder, true);
- dispatchChangeStarting(newHolder, false);
- dispatchChangeFinished(newHolder, false);
- return true;
- }
-
- @Override
- public void endAnimation(RecyclerView.ViewHolder item) {
- }
-
- @Override
- public void endAnimations() {
- }
-
- @Override
- public boolean isRunning() {
- return false;
- }
-}
Oops, something went wrong.

0 comments on commit 6ec5654

Please sign in to comment.