Browse Source

Fix crash when clicking back button in a Modal

Guy Carmeli 8 years ago
parent
commit
b7f7fb26c6

+ 9
- 5
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java View File

380
 
380
 
381
     @Override
381
     @Override
382
     public void onBackPressed() {
382
     public void onBackPressed() {
383
+        ModalController modalController = ModalController.getInstance();
384
+        if (modalController.isModalDisplayed()) {
385
+            modalController.dismissModal();
386
+            return;
387
+        }
388
+
383
         if (getScreenStackSize() > 1) {
389
         if (getScreenStackSize() > 1) {
384
             pop(getCurrentNavigatorId());
390
             pop(getCurrentNavigatorId());
391
+        } else if (mReactInstanceManager != null) {
392
+            mReactInstanceManager.onBackPressed();
385
         } else {
393
         } else {
386
-            if (mReactInstanceManager != null) {
387
-                mReactInstanceManager.onBackPressed();
388
-            } else {
389
-                super.onBackPressed();
390
-            }
394
+            super.onBackPressed();
391
         }
395
         }
392
     }
396
     }
393
 
397