Quellcode durchsuchen

Fix crash when SideMenu closes

fixes #1586 #1585 #1584
Guy Carmeli vor 7 Jahren
Ursprung
Commit
6bb45032ec

+ 7
- 2
android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java Datei anzeigen

@@ -43,6 +43,7 @@ public class SideMenu extends DrawerLayout {
43 43
     }
44 44
 
45 45
     public void destroy() {
46
+        removeDrawerListener(sideMenuListener);
46 47
         destroySideMenu(leftSideMenuView);
47 48
         destroySideMenu(rightSideMenuView);
48 49
     }
@@ -146,13 +147,17 @@ public class SideMenu extends DrawerLayout {
146 147
 
147 148
             @Override
148 149
             public void onDrawerClosed(View drawerView) {
149
-                NavigationApplication.instance.getEventEmitter().sendWillDisappearEvent(getVisibleDrawerScreenParams(), NavigationType.CloseSideMenu);
150
-                NavigationApplication.instance.getEventEmitter().sendDidDisappearEvent(getVisibleDrawerScreenParams(), NavigationType.CloseSideMenu);
150
+                NavigationApplication.instance.getEventEmitter().sendWillDisappearEvent(getVisibleDrawerScreenParams((ContentView) drawerView), NavigationType.CloseSideMenu);
151
+                NavigationApplication.instance.getEventEmitter().sendDidDisappearEvent(getVisibleDrawerScreenParams((ContentView) drawerView), NavigationType.CloseSideMenu);
151 152
             }
152 153
 
153 154
             private BaseScreenParams getVisibleDrawerScreenParams() {
154 155
                 return isDrawerOpen(Side.Left.gravity) ? leftMenuParams : rightMenuParams;
155 156
             }
157
+
158
+            private BaseScreenParams getVisibleDrawerScreenParams(ContentView drawerView) {
159
+                return drawerView == leftSideMenuView ? leftMenuParams : rightMenuParams;
160
+            }
156 161
         };
157 162
         addDrawerListener(sideMenuListener);
158 163
     }