Parcourir la source

Fix crash when clicking back button in a Modal

Guy Carmeli il y a 8 ans
Parent
révision
b7f7fb26c6

+ 9
- 5
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java Voir le fichier

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