|
@@ -23,26 +23,6 @@ public class RctView extends FrameLayout {
|
23
|
23
|
private BottomTabActivity context;
|
24
|
24
|
private ReactRootView reactRootView;
|
25
|
25
|
private ScrollView scrollView;
|
26
|
|
- private int lastScrollY = -1;
|
27
|
|
- private final ViewTreeObserver.OnScrollChangedListener scrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() {
|
28
|
|
- @Override
|
29
|
|
- public void onScrollChanged() {
|
30
|
|
- if (!scrollView.getViewTreeObserver().isAlive()) {
|
31
|
|
- return;
|
32
|
|
- }
|
33
|
|
-
|
34
|
|
- final int scrollY = scrollView.getScrollY();
|
35
|
|
- if (scrollY != lastScrollY && // Scroll position changed
|
36
|
|
- scrollY > 0 && // Ignore top overscroll
|
37
|
|
- scrollY < (scrollView.getChildAt(0).getHeight() - scrollView.getHeight())) { // Ignore bottom overscroll
|
38
|
|
- int direction = scrollY > lastScrollY ?
|
39
|
|
- BottomNavigation.SCROLL_DIRECTION_DOWN :
|
40
|
|
- BottomNavigation.SCROLL_DIRECTION_UP;
|
41
|
|
- lastScrollY = scrollY;
|
42
|
|
- context.onScrollChanged(direction);
|
43
|
|
- }
|
44
|
|
- }
|
45
|
|
- };
|
46
|
26
|
private boolean isScrollEventListenerRegistered = false;
|
47
|
27
|
|
48
|
28
|
private final View.OnAttachStateChangeListener stateChangeListener =
|
|
@@ -90,16 +70,16 @@ public class RctView extends FrameLayout {
|
90
|
70
|
setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
91
|
71
|
|
92
|
72
|
final OnDisplayedListener onDisplayedListenerInternal = screen.bottomTabsHiddenOnScroll ?
|
93
|
|
- new OnDisplayedListener() {
|
94
|
|
- @Override
|
95
|
|
- public void onDisplayed() {
|
96
|
|
- if (onDisplayedListener != null) {
|
97
|
|
- onDisplayedListener.onDisplayed();
|
98
|
|
- }
|
|
73
|
+ new OnDisplayedListener() {
|
|
74
|
+ @Override
|
|
75
|
+ public void onDisplayed() {
|
|
76
|
+ if (onDisplayedListener != null) {
|
|
77
|
+ onDisplayedListener.onDisplayed();
|
|
78
|
+ }
|
99
|
79
|
|
100
|
|
- setupScrollViewWithBottomTabs();
|
101
|
|
- }
|
102
|
|
- } : onDisplayedListener;
|
|
80
|
+ setupScrollViewWithBottomTabs();
|
|
81
|
+ }
|
|
82
|
+ } : onDisplayedListener;
|
103
|
83
|
|
104
|
84
|
reactRootView = new RnnReactRootView(ctx, onDisplayedListenerInternal);
|
105
|
85
|
reactRootView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
|
@@ -130,21 +110,6 @@ public class RctView extends FrameLayout {
|
130
|
110
|
}
|
131
|
111
|
}
|
132
|
112
|
|
133
|
|
- private ScrollView getScrollView(ViewGroup parent) {
|
134
|
|
- for (int i = 0; i < parent.getChildCount(); i++) {
|
135
|
|
- View child = parent.getChildAt(i);
|
136
|
|
-
|
137
|
|
- if (child instanceof ScrollView) {
|
138
|
|
- return (ScrollView) child;
|
139
|
|
- }
|
140
|
|
-
|
141
|
|
- if (child instanceof ViewGroup) {
|
142
|
|
- return getScrollView((ViewGroup) child);
|
143
|
|
- }
|
144
|
|
- }
|
145
|
|
-
|
146
|
|
- return null;
|
147
|
|
- }
|
148
|
113
|
|
149
|
114
|
private void attachStateChangeListener(ScrollView scrollView) {
|
150
|
115
|
scrollView.addOnAttachStateChangeListener(stateChangeListener);
|