浏览代码

Fix crash when SideMenu closes

fixes #1586 #1585 #1584
Guy Carmeli 7 年前
父节点
当前提交
6bb45032ec
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7
    2
      android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java

+ 7
- 2
android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java 查看文件

@@ -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
     }