Преглед на файлове

Fix ContextualMenu show animation

Also removes ContextualMenu after it is dismissed
Guy Carmeli преди 8 години
родител
ревизия
3f6bbd776c

+ 7
- 1
android/app/src/main/java/com/reactnativenavigation/views/ContextualMenu.java Целия файл

@@ -2,6 +2,7 @@ package com.reactnativenavigation.views;
2 2
 
3 3
 import android.content.Context;
4 4
 import android.view.Menu;
5
+import android.view.ViewManager;
5 6
 
6 7
 import com.facebook.react.bridge.Callback;
7 8
 import com.reactnativenavigation.NavigationApplication;
@@ -71,7 +72,12 @@ public class ContextualMenu extends TitleBar implements LeftButtonOnClickListene
71 72
     }
72 73
 
73 74
     public void dismiss() {
74
-        hide();
75
+        hide(new Runnable() {
76
+            @Override
77
+            public void run() {
78
+                ((ViewManager) getParent()).removeView(ContextualMenu.this);
79
+            }
80
+        });
75 81
         NavigationApplication.instance.sendNavigatorEvent("contextualMenuDismissed", navigatorEventId);
76 82
     }
77 83
 }

+ 16
- 5
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Целия файл

@@ -1,7 +1,10 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
+import android.animation.Animator;
4
+import android.animation.AnimatorListenerAdapter;
3 5
 import android.content.Context;
4 6
 import android.graphics.drawable.Drawable;
7
+import android.support.annotation.Nullable;
5 8
 import android.support.v7.widget.ActionMenuView;
6 9
 import android.support.v7.widget.Toolbar;
7 10
 import android.view.Menu;
@@ -141,17 +144,25 @@ public class TitleBar extends Toolbar {
141 144
     }
142 145
 
143 146
     public void hide() {
147
+        hide(null);
148
+    }
149
+
150
+    public void hide(@Nullable final Runnable onHidden) {
144 151
         animate()
145 152
                 .alpha(0)
146 153
                 .setDuration(200)
147
-                .setInterpolator(new AccelerateInterpolator());
154
+                .setInterpolator(new AccelerateInterpolator())
155
+                .setListener(new AnimatorListenerAdapter() {
156
+                    @Override
157
+                    public void onAnimationEnd(Animator animation) {
158
+                        if (onHidden != null) {
159
+                            onHidden.run();
160
+                        }
161
+                    }
162
+                });
148 163
     }
149 164
 
150 165
     public void show() {
151
-        if (getAlpha() == 1) {
152
-            return;
153
-        }
154
-
155 166
         setAlpha(0);
156 167
         animate()
157 168
                 .alpha(1)