@Test public void removeViewFromTop() { List<MockView> views = pushThreeViewsToStack(); final MockView remove = views.get(2); final Dual<NavigationDetails, Boolean> removedViewMetadata = viewManager.removeViewFromStack(remove); assertThat(removedViewMetadata).isNotNull(); assertThat(removedViewMetadata.first().view()).isEqualTo(remove); assertThat(removedViewMetadata.second()).isEqualTo(Boolean.TRUE); }
@VisibleForTesting @Nullable @MainThread Dual<NavigationDetails, Boolean> removeViewFromStack(@NonNull ContentViewContract removableView) { final Iterator<NavigationDetails> iterator = viewStack.iterator(); boolean top = true; while (iterator.hasNext()) { final NavigationDetails next = iterator.next(); final ContentViewContract nextViewContract = next.view(); final boolean equal = removableView.equals(nextViewContract); if (top) { if (equal) { iterator.remove(); return Dual.create(next, Boolean.TRUE); } top = false; } else if (equal) { iterator.remove(); return Dual.create(next, Boolean.FALSE); } } return null; }
ViewManager implements Observer<LifecycleEvent> { @VisibleForTesting @Nullable @MainThread Dual<NavigationDetails, Boolean> removeViewFromStack(@NonNull ContentViewContract removableView) { final Iterator<NavigationDetails> iterator = viewStack.iterator(); boolean top = true; while (iterator.hasNext()) { final NavigationDetails next = iterator.next(); final ContentViewContract nextViewContract = next.view(); final boolean equal = removableView.equals(nextViewContract); if (top) { if (equal) { iterator.remove(); return Dual.create(next, Boolean.TRUE); } top = false; } else if (equal) { iterator.remove(); return Dual.create(next, Boolean.FALSE); } } return null; } }
ViewManager implements Observer<LifecycleEvent> { @VisibleForTesting @Nullable @MainThread Dual<NavigationDetails, Boolean> removeViewFromStack(@NonNull ContentViewContract removableView) { final Iterator<NavigationDetails> iterator = viewStack.iterator(); boolean top = true; while (iterator.hasNext()) { final NavigationDetails next = iterator.next(); final ContentViewContract nextViewContract = next.view(); final boolean equal = removableView.equals(nextViewContract); if (top) { if (equal) { iterator.remove(); return Dual.create(next, Boolean.TRUE); } top = false; } else if (equal) { iterator.remove(); return Dual.create(next, Boolean.FALSE); } } return null; } ViewManager(@NonNull GraphProvider graphProvider); }
ViewManager implements Observer<LifecycleEvent> { @VisibleForTesting @Nullable @MainThread Dual<NavigationDetails, Boolean> removeViewFromStack(@NonNull ContentViewContract removableView) { final Iterator<NavigationDetails> iterator = viewStack.iterator(); boolean top = true; while (iterator.hasNext()) { final NavigationDetails next = iterator.next(); final ContentViewContract nextViewContract = next.view(); final boolean equal = removableView.equals(nextViewContract); if (top) { if (equal) { iterator.remove(); return Dual.create(next, Boolean.TRUE); } top = false; } else if (equal) { iterator.remove(); return Dual.create(next, Boolean.FALSE); } } return 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> { @VisibleForTesting @Nullable @MainThread Dual<NavigationDetails, Boolean> removeViewFromStack(@NonNull ContentViewContract removableView) { final Iterator<NavigationDetails> iterator = viewStack.iterator(); boolean top = true; while (iterator.hasNext()) { final NavigationDetails next = iterator.next(); final ContentViewContract nextViewContract = next.view(); final boolean equal = removableView.equals(nextViewContract); if (top) { if (equal) { iterator.remove(); return Dual.create(next, Boolean.TRUE); } top = false; } else if (equal) { iterator.remove(); return Dual.create(next, Boolean.FALSE); } } return 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();  }