@Test public void finishFromOnDestroyAfterSuperDoesNothing() { final MockView secondView = spy(new MockView() { @Override public void onDestroy() { super.onDestroy(); viewManager.finish(this); } }); assertFinishFromOnDestroyDoesNoting(secondView); }
@MainThread void finish(@NonNull ContentViewContract view) { final Dual<NavigationDetails, Boolean> removedViewMetadata = removeViewFromStack(view); if (removedViewMetadata == null) { LogUtil.logViewWarning(TAG, "Tried to remove non-existing view %s; ignore and carry on", view); return; } final Boolean top = removedViewMetadata.second(); final NavigationDetails removed = removedViewMetadata.first(); final ContentViewContract removedView = removed.view(); final LifecycleEvent latestLifecycleEvent = removedView.latestLifecycleEvent(); if (top && latestLifecycleEvent != STOP) { removedView.onStop(); } removedView.onDestroy(); if (top && latestLifecycleEvent != STOP) { final NavigationDetails newTop = viewStack.peek(); if (newTop != null) { if (newTop.needsRestart()) { final NavigationDetails restartedNavDetails = viewStack.pollFirst().restart(); viewStack.push(restartedNavDetails); transitionBetween(restartedNavDetails, removed, false); callViewStartMethods(restartedNavDetails.view(), true); } else { transitionBetween(newTop, removed, false); final ContentViewContract newTopView = newTop.view(); if (newTopView.latestLifecycleEvent() != START) { newTopView.onStart(); } } } } removedView.setRootView(null); }
ViewManager implements Observer<LifecycleEvent> { @MainThread void finish(@NonNull ContentViewContract view) { final Dual<NavigationDetails, Boolean> removedViewMetadata = removeViewFromStack(view); if (removedViewMetadata == null) { LogUtil.logViewWarning(TAG, "Tried to remove non-existing view %s; ignore and carry on", view); return; } final Boolean top = removedViewMetadata.second(); final NavigationDetails removed = removedViewMetadata.first(); final ContentViewContract removedView = removed.view(); final LifecycleEvent latestLifecycleEvent = removedView.latestLifecycleEvent(); if (top && latestLifecycleEvent != STOP) { removedView.onStop(); } removedView.onDestroy(); if (top && latestLifecycleEvent != STOP) { final NavigationDetails newTop = viewStack.peek(); if (newTop != null) { if (newTop.needsRestart()) { final NavigationDetails restartedNavDetails = viewStack.pollFirst().restart(); viewStack.push(restartedNavDetails); transitionBetween(restartedNavDetails, removed, false); callViewStartMethods(restartedNavDetails.view(), true); } else { transitionBetween(newTop, removed, false); final ContentViewContract newTopView = newTop.view(); if (newTopView.latestLifecycleEvent() != START) { newTopView.onStart(); } } } } removedView.setRootView(null); } }
ViewManager implements Observer<LifecycleEvent> { @MainThread void finish(@NonNull ContentViewContract view) { final Dual<NavigationDetails, Boolean> removedViewMetadata = removeViewFromStack(view); if (removedViewMetadata == null) { LogUtil.logViewWarning(TAG, "Tried to remove non-existing view %s; ignore and carry on", view); return; } final Boolean top = removedViewMetadata.second(); final NavigationDetails removed = removedViewMetadata.first(); final ContentViewContract removedView = removed.view(); final LifecycleEvent latestLifecycleEvent = removedView.latestLifecycleEvent(); if (top && latestLifecycleEvent != STOP) { removedView.onStop(); } removedView.onDestroy(); if (top && latestLifecycleEvent != STOP) { final NavigationDetails newTop = viewStack.peek(); if (newTop != null) { if (newTop.needsRestart()) { final NavigationDetails restartedNavDetails = viewStack.pollFirst().restart(); viewStack.push(restartedNavDetails); transitionBetween(restartedNavDetails, removed, false); callViewStartMethods(restartedNavDetails.view(), true); } else { transitionBetween(newTop, removed, false); final ContentViewContract newTopView = newTop.view(); if (newTopView.latestLifecycleEvent() != START) { newTopView.onStart(); } } } } removedView.setRootView(null); } ViewManager(@NonNull GraphProvider graphProvider); }
ViewManager implements Observer<LifecycleEvent> { @MainThread void finish(@NonNull ContentViewContract view) { final Dual<NavigationDetails, Boolean> removedViewMetadata = removeViewFromStack(view); if (removedViewMetadata == null) { LogUtil.logViewWarning(TAG, "Tried to remove non-existing view %s; ignore and carry on", view); return; } final Boolean top = removedViewMetadata.second(); final NavigationDetails removed = removedViewMetadata.first(); final ContentViewContract removedView = removed.view(); final LifecycleEvent latestLifecycleEvent = removedView.latestLifecycleEvent(); if (top && latestLifecycleEvent != STOP) { removedView.onStop(); } removedView.onDestroy(); if (top && latestLifecycleEvent != STOP) { final NavigationDetails newTop = viewStack.peek(); if (newTop != null) { if (newTop.needsRestart()) { final NavigationDetails restartedNavDetails = viewStack.pollFirst().restart(); viewStack.push(restartedNavDetails); transitionBetween(restartedNavDetails, removed, false); callViewStartMethods(restartedNavDetails.view(), true); } else { transitionBetween(newTop, removed, false); final ContentViewContract newTopView = newTop.view(); if (newTopView.latestLifecycleEvent() != START) { newTopView.onStart(); } } } } removedView.setRootView(null); } ViewManager(@NonNull GraphProvider graphProvider); @MainThread final void registerActivity(@NonNull RootActivityContract activityContract,
                                     @NonNull Activity rootActivity); @MainThread final void unregisterActivity(); @Override void onNext(LifecycleEvent lifecycleEvent); @Override void onCompleted(); @Override void onError(Throwable e); @MainThread final boolean handleBackPress(); }
ViewManager implements Observer<LifecycleEvent> { @MainThread void finish(@NonNull ContentViewContract view) { final Dual<NavigationDetails, Boolean> removedViewMetadata = removeViewFromStack(view); if (removedViewMetadata == null) { LogUtil.logViewWarning(TAG, "Tried to remove non-existing view %s; ignore and carry on", view); return; } final Boolean top = removedViewMetadata.second(); final NavigationDetails removed = removedViewMetadata.first(); final ContentViewContract removedView = removed.view(); final LifecycleEvent latestLifecycleEvent = removedView.latestLifecycleEvent(); if (top && latestLifecycleEvent != STOP) { removedView.onStop(); } removedView.onDestroy(); if (top && latestLifecycleEvent != STOP) { final NavigationDetails newTop = viewStack.peek(); if (newTop != null) { if (newTop.needsRestart()) { final NavigationDetails restartedNavDetails = viewStack.pollFirst().restart(); viewStack.push(restartedNavDetails); transitionBetween(restartedNavDetails, removed, false); callViewStartMethods(restartedNavDetails.view(), true); } else { transitionBetween(newTop, removed, false); final ContentViewContract newTopView = newTop.view(); if (newTopView.latestLifecycleEvent() != START) { newTopView.onStart(); } } } } removedView.setRootView(null); } ViewManager(@NonNull GraphProvider graphProvider); @MainThread final void registerActivity(@NonNull RootActivityContract activityContract,
                                     @NonNull Activity rootActivity); @MainThread final void unregisterActivity(); @Override void onNext(LifecycleEvent lifecycleEvent); @Override void onCompleted(); @Override void onError(Throwable e); @MainThread final boolean handleBackPress();  }