Browse Source

Relax with the scaled touch slop checks

No need to check it twice
Guy Carmeli 7 years ago
parent
commit
c1b99bf79b

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapseCalculator.java View File

@@ -122,8 +122,8 @@ public class CollapseCalculator {
122 122
         }
123 123
         checkCollapseLimits();
124 124
         return (isNotCollapsedOrExpended() ||
125
-               (canCollapse && isExpendedAndScrollingUp(direction) && collapseBehaviour.canCollapse(scrollView.getScrollY(), scaledTouchSlop)) ||
126
-               (canExpend && isCollapsedAndScrollingDown(direction) && collapseBehaviour.canExpend(scrollView.getScrollY(), scaledTouchSlop))
125
+               (canCollapse && isExpendedAndScrollingUp(direction)) ||
126
+               (canExpend && isCollapsedAndScrollingDown(direction) && collapseBehaviour.canExpend(scrollView.getScrollY()))
127 127
         );
128 128
     }
129 129
 

+ 1
- 3
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/behaviours/CollapseBehaviour.java View File

@@ -5,7 +5,5 @@ public interface CollapseBehaviour {
5 5
 
6 6
     boolean shouldCollapseOnTouchUp();
7 7
 
8
-    boolean canCollapse(int scrollY, int scaledTouchSlop);
9
-
10
-    boolean canExpend(int scrollY, int scaledTouchSlop);
8
+    boolean canExpend(int scrollY);
11 9
 }

+ 1
- 6
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/behaviours/CollapseTitleBarBehaviour.java View File

@@ -12,12 +12,7 @@ public class CollapseTitleBarBehaviour implements CollapseBehaviour {
12 12
     }
13 13
 
14 14
     @Override
15
-    public boolean canCollapse(int scrollY, int scaledTouchSlop) {
16
-        return true;
17
-    }
18
-
19
-    @Override
20
-    public boolean canExpend(int scrollY, int scaledTouchSlop) {
15
+    public boolean canExpend(int scrollY) {
21 16
         return true;
22 17
     }
23 18
 }

+ 2
- 7
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/behaviours/CollapseTopBarBehaviour.java View File

@@ -12,12 +12,7 @@ public class CollapseTopBarBehaviour implements CollapseBehaviour {
12 12
     }
13 13
 
14 14
     @Override
15
-    public boolean canCollapse(int scrollY, int scaledTouchSlop) {
16
-        return scrollY <= scaledTouchSlop;
17
-    }
18
-
19
-    @Override
20
-    public boolean canExpend(int scrollY, int scaledTouchSlop) {
21
-        return scrollY <= scaledTouchSlop;
15
+    public boolean canExpend(int scrollY) {
16
+        return scrollY == 0;
22 17
     }
23 18
 }

+ 1
- 6
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/behaviours/TitleBarHideOnScrollBehaviour.java View File

@@ -12,12 +12,7 @@ public class TitleBarHideOnScrollBehaviour implements CollapseBehaviour {
12 12
     }
13 13
 
14 14
     @Override
15
-    public boolean canCollapse(int scrollY, int scaledTouchSlop) {
16
-        return true;
17
-    }
18
-
19
-    @Override
20
-    public boolean canExpend(int scrollY, int scaledTouchSlop) {
15
+    public boolean canExpend(int scrollY) {
21 16
         return true;
22 17
     }
23 18
 }