|
@@ -29,16 +29,19 @@ public class RctView extends FrameLayout {
|
29
|
29
|
private final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() {
|
30
|
30
|
@Override
|
31
|
31
|
public void onScrollChanged() {
|
32
|
|
- if (mScrollView.getViewTreeObserver().isAlive()) {
|
33
|
|
- if (mScrollView.getScrollY() != mLastScrollY) {
|
34
|
|
- int currentScrollY = mScrollView.getScrollY();
|
35
|
|
- mContext.notifyScroll(currentScrollY > mLastScrollY ?
|
36
|
|
- BottomNavigation.SCROLL_DIRECTION_DOWN :
|
37
|
|
- BottomNavigation.SCROLL_DIRECTION_UP);
|
38
|
|
-
|
39
|
|
- mLastScrollY = currentScrollY;
|
40
|
|
- }
|
41
|
|
- Log.i(TAG, "onScrollChanged: " + mLastScrollY);
|
|
32
|
+ if (!mScrollView.getViewTreeObserver().isAlive()) {
|
|
33
|
+ return;
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ final int scrollY = mScrollView.getScrollY();
|
|
37
|
+ if (scrollY != mLastScrollY && // Scroll position changed
|
|
38
|
+ scrollY > 0 && // Ignore top overscroll
|
|
39
|
+ scrollY < (mScrollView.getChildAt(0).getHeight() - mScrollView.getHeight())) { // Ignore bottom overscroll
|
|
40
|
+ int direction = scrollY > mLastScrollY ?
|
|
41
|
+ BottomNavigation.SCROLL_DIRECTION_DOWN :
|
|
42
|
+ BottomNavigation.SCROLL_DIRECTION_UP;
|
|
43
|
+ mLastScrollY = scrollY;
|
|
44
|
+ mContext.onScrollChanged(direction);
|
42
|
45
|
}
|
43
|
46
|
}
|
44
|
47
|
};
|