|
@@ -6,8 +6,6 @@ import android.animation.ObjectAnimator;
|
6
|
6
|
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
|
7
|
7
|
import android.view.View;
|
8
|
8
|
|
9
|
|
-import com.reactnativenavigation.views.ScrollDirectionListener;
|
10
|
|
-
|
11
|
9
|
public class VisibilityAnimator {
|
12
|
10
|
|
13
|
11
|
public enum HideDirection {
|
|
@@ -22,24 +20,14 @@ public class VisibilityAnimator {
|
22
|
20
|
private static final int DURATION = 300;
|
23
|
21
|
|
24
|
22
|
private final View view;
|
25
|
|
- private final HideDirection hideDirection;
|
26
|
23
|
private final int hiddenEndValue;
|
27
|
24
|
private VisibilityState visibilityState = VisibilityState.Shown;
|
28
|
25
|
|
29
|
26
|
public VisibilityAnimator(View view, HideDirection hideDirection, int height) {
|
30
|
27
|
this.view = view;
|
31
|
|
- this.hideDirection = hideDirection;
|
32
|
28
|
this.hiddenEndValue = hideDirection == HideDirection.Up ? -height : height;
|
33
|
29
|
}
|
34
|
30
|
|
35
|
|
- public void onScrollChanged(ScrollDirectionListener.Direction scrollDirection) {
|
36
|
|
- if (hideDirection == HideDirection.Down) {
|
37
|
|
- handleDownHidingViews(scrollDirection);
|
38
|
|
- } else {
|
39
|
|
- handleUpHidingViews(scrollDirection);
|
40
|
|
- }
|
41
|
|
- }
|
42
|
|
-
|
43
|
31
|
public void setVisible(boolean visible, boolean animate) {
|
44
|
32
|
if (visible && isHiding()) {
|
45
|
33
|
show(animate);
|
|
@@ -48,22 +36,6 @@ public class VisibilityAnimator {
|
48
|
36
|
}
|
49
|
37
|
}
|
50
|
38
|
|
51
|
|
- private void handleUpHidingViews(ScrollDirectionListener.Direction scrollDirection) {
|
52
|
|
- if (scrollUp(scrollDirection) && !isShowing()) {
|
53
|
|
- show(true);
|
54
|
|
- } else if (scrollDown(scrollDirection) && !isHiding()) {
|
55
|
|
- hide(true);
|
56
|
|
- }
|
57
|
|
- }
|
58
|
|
-
|
59
|
|
- private void handleDownHidingViews(ScrollDirectionListener.Direction scrollDirection) {
|
60
|
|
- if (scrollDown(scrollDirection) && !isHiding()) {
|
61
|
|
- hide(true);
|
62
|
|
- } else if (scrollUp(scrollDirection) && !isShowing()) {
|
63
|
|
- show(true);
|
64
|
|
- }
|
65
|
|
- }
|
66
|
|
-
|
67
|
39
|
private void show(boolean animate) {
|
68
|
40
|
if (animate) {
|
69
|
41
|
ObjectAnimator animator = createAnimator(true);
|
|
@@ -84,14 +56,6 @@ public class VisibilityAnimator {
|
84
|
56
|
}
|
85
|
57
|
}
|
86
|
58
|
|
87
|
|
- private boolean scrollUp(ScrollDirectionListener.Direction scrollDirection) {
|
88
|
|
- return scrollDirection == ScrollDirectionListener.Direction.Up;
|
89
|
|
- }
|
90
|
|
-
|
91
|
|
- private boolean scrollDown(ScrollDirectionListener.Direction scrollDirection) {
|
92
|
|
- return scrollDirection == ScrollDirectionListener.Direction.Down;
|
93
|
|
- }
|
94
|
|
-
|
95
|
59
|
private boolean isShowing() {
|
96
|
60
|
return visibilityState == VisibilityState.Shown || visibilityState == VisibilityState.AnimateShow;
|
97
|
61
|
}
|