diff --git a/demo/src/main/java/com/bluelinelabs/conductor/demo/controllers/ParentController.java b/demo/src/main/java/com/bluelinelabs/conductor/demo/controllers/ParentController.java index 62fdafd3..5a72ad4a 100644 --- a/demo/src/main/java/com/bluelinelabs/conductor/demo/controllers/ParentController.java +++ b/demo/src/main/java/com/bluelinelabs/conductor/demo/controllers/ParentController.java @@ -50,17 +50,19 @@ private void addChild(final int index) { childController.addLifecycleListener(new LifecycleListener() { @Override public void onChangeEnd(@NonNull Controller controller, @NonNull ControllerChangeHandler changeHandler, @NonNull ControllerChangeType changeType) { - if (changeType == ControllerChangeType.PUSH_ENTER && !hasShownAll) { - if (index < NUMBER_OF_CHILDREN - 1) { - addChild(index + 1); - } else { - hasShownAll = true; - } - } else if (changeType == ControllerChangeType.POP_EXIT) { - if (index > 0) { - removeChild(index - 1); - } else { - getRouter().popController(ParentController.this); + if (!isBeingDestroyed()) { + if (changeType == ControllerChangeType.PUSH_ENTER && !hasShownAll) { + if (index < NUMBER_OF_CHILDREN - 1) { + addChild(index + 1); + } else { + hasShownAll = true; + } + } else if (changeType == ControllerChangeType.POP_EXIT) { + if (index > 0) { + removeChild(index - 1); + } else { + getRouter().popController(ParentController.this); + } } } }