Browse Source

visibilityAnimator refactor

Daniel Zlotin 8 years ago
parent
commit
878c0009d6

+ 3
- 4
android/app/src/main/java/com/reactnativenavigation/animation/VisibilityAnimator.java View File

@@ -8,7 +8,6 @@ import android.view.View;
8 8
 
9 9
 import com.reactnativenavigation.views.ScrollDirectionListener;
10 10
 
11
-// TODO find a better name for this class
12 11
 public class VisibilityAnimator {
13 12
 
14 13
     public enum HideDirection {
@@ -42,10 +41,10 @@ public class VisibilityAnimator {
42 41
     }
43 42
 
44 43
     public void setVisible(boolean visible, boolean animate) {
45
-        if (isShowing() && !visible) {
46
-            hide(animate);
47
-        } else if (isHiding() && visible) {
44
+        if (visible && isHiding()) {
48 45
             show(animate);
46
+        } else if (!visible && isShowing()) {
47
+            hide(animate);
49 48
         }
50 49
     }
51 50
 

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java View File

@@ -59,7 +59,7 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
59 59
 
60 60
     @ReactMethod
61 61
     public void setTopBarVisible(String screenInstanceID, boolean hidden, boolean animated) {
62
-        NavigationCommandsHandler.toggleTopBarVisible(screenInstanceID, hidden, animated);
62
+        NavigationCommandsHandler.setTopBarVisible(screenInstanceID, hidden, animated);
63 63
     }
64 64
 
65 65
     @ReactMethod

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java View File

@@ -90,7 +90,7 @@ public class NavigationCommandsHandler {
90 90
         });
91 91
     }
92 92
 
93
-    public static void toggleTopBarVisible(final String screenInstanceID, final boolean hidden, final boolean animated) {
93
+    public static void setTopBarVisible(final String screenInstanceID, final boolean hidden, final boolean animated) {
94 94
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
95 95
         if (currentActivity == null) {
96 96
             return;

+ 3
- 6
android/app/src/main/java/com/reactnativenavigation/layouts/ScreenStack.java View File

@@ -6,7 +6,6 @@ import android.widget.FrameLayout;
6 6
 
7 7
 import com.reactnativenavigation.params.ScreenParams;
8 8
 
9
-import java.util.Iterator;
10 9
 import java.util.Stack;
11 10
 
12 11
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
@@ -98,11 +97,9 @@ public class ScreenStack extends FrameLayout {
98 97
             return null;
99 98
         }
100 99
 
101
-        Iterator<Screen> iterator = stack.iterator();
102
-        while (iterator.hasNext()) {
103
-            Screen next = iterator.next();
104
-            if (next.getScreenInstanceId().equals(screenInstanceId)) {
105
-                return next;
100
+        for (Screen screen : stack) {
101
+            if (screen.getScreenInstanceId().equals(screenInstanceId)) {
102
+                return screen;
106 103
             }
107 104
         }
108 105
 

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/views/ScrollViewAttacher.java View File

@@ -22,7 +22,7 @@ public class ScrollViewAttacher {
22 22
         }
23 23
     }
24 24
 
25
-    public void detach() {
25
+    private void detach() {
26 26
         if (scrollView != null) {
27 27
             scrollView.getViewTreeObserver().removeOnScrollChangedListener(scrollDirectionListener);
28 28
             scrollDirectionListener = null;