Browse Source

Fix crash when SideMenu closes

fixes #1586 #1585 #1584
Guy Carmeli 7 years ago
parent
commit
6bb45032ec

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

43
     }
43
     }
44
 
44
 
45
     public void destroy() {
45
     public void destroy() {
46
+        removeDrawerListener(sideMenuListener);
46
         destroySideMenu(leftSideMenuView);
47
         destroySideMenu(leftSideMenuView);
47
         destroySideMenu(rightSideMenuView);
48
         destroySideMenu(rightSideMenuView);
48
     }
49
     }
146
 
147
 
147
             @Override
148
             @Override
148
             public void onDrawerClosed(View drawerView) {
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
             private BaseScreenParams getVisibleDrawerScreenParams() {
154
             private BaseScreenParams getVisibleDrawerScreenParams() {
154
                 return isDrawerOpen(Side.Left.gravity) ? leftMenuParams : rightMenuParams;
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
         addDrawerListener(sideMenuListener);
162
         addDrawerListener(sideMenuListener);
158
     }
163
     }