@Test public void push_assignsRefToSelfOnPushedController() { assertThat(child1.getParentController()).isNull(); uut.push(child1, new CommandListenerAdapter()); assertThat(child1.getParentController()).isEqualTo(uut); StackController anotherNavController = createStack("another"); anotherNavController.ensureViewIsCreated(); anotherNavController.push(child2, new CommandListenerAdapter()); assertThat(child2.getParentController()).isEqualTo(anotherNavController); }
public void push(ViewController child, CommandListener listener) { final ViewController toRemove = stack.peek(); if (size() > 0) backButtonHelper.addToPushedChild(child); child.setParentController(this); stack.push(child.getId(), child); Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions()); addChildToStack(child, child.getView(), resolvedOptions); if (toRemove != null) { if (resolvedOptions.animations.push.enabled.isTrueOrUndefined()) { if (resolvedOptions.animations.push.waitForRender.isTrue()) { child.getView().setAlpha(0); child.setOnAppearedListener(() -> animator.push(child.getView(), resolvedOptions.animations.push, resolvedOptions.transitions, toRemove.getElements(), child.getElements(), () -> { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); })); } else { animator.push(child.getView(), resolvedOptions.animations.push, () -> { if (!toRemove.equals(peek())) { getView().removeView(toRemove.getView()); } listener.onSuccess(child.getId()); }); } } else { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); } } else { listener.onSuccess(child.getId()); } }
StackController extends ParentController<StackLayout> { public void push(ViewController child, CommandListener listener) { final ViewController toRemove = stack.peek(); if (size() > 0) backButtonHelper.addToPushedChild(child); child.setParentController(this); stack.push(child.getId(), child); Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions()); addChildToStack(child, child.getView(), resolvedOptions); if (toRemove != null) { if (resolvedOptions.animations.push.enabled.isTrueOrUndefined()) { if (resolvedOptions.animations.push.waitForRender.isTrue()) { child.getView().setAlpha(0); child.setOnAppearedListener(() -> animator.push(child.getView(), resolvedOptions.animations.push, resolvedOptions.transitions, toRemove.getElements(), child.getElements(), () -> { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); })); } else { animator.push(child.getView(), resolvedOptions.animations.push, () -> { if (!toRemove.equals(peek())) { getView().removeView(toRemove.getView()); } listener.onSuccess(child.getId()); }); } } else { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); } } else { listener.onSuccess(child.getId()); } } }
StackController extends ParentController<StackLayout> { public void push(ViewController child, CommandListener listener) { final ViewController toRemove = stack.peek(); if (size() > 0) backButtonHelper.addToPushedChild(child); child.setParentController(this); stack.push(child.getId(), child); Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions()); addChildToStack(child, child.getView(), resolvedOptions); if (toRemove != null) { if (resolvedOptions.animations.push.enabled.isTrueOrUndefined()) { if (resolvedOptions.animations.push.waitForRender.isTrue()) { child.getView().setAlpha(0); child.setOnAppearedListener(() -> animator.push(child.getView(), resolvedOptions.animations.push, resolvedOptions.transitions, toRemove.getElements(), child.getElements(), () -> { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); })); } else { animator.push(child.getView(), resolvedOptions.animations.push, () -> { if (!toRemove.equals(peek())) { getView().removeView(toRemove.getView()); } listener.onSuccess(child.getId()); }); } } else { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); } } else { listener.onSuccess(child.getId()); } } StackController(Activity activity, List<ViewController> children, ChildControllersRegistry childRegistry, TopBarBackgroundViewController topBarBackgroundViewController, TopBarController topBarController, NavigationAnimator animator, String id, Options initialOptions, BackButtonHelper backButtonHelper, StackPresenter stackPresenter, Presenter presenter); }
StackController extends ParentController<StackLayout> { public void push(ViewController child, CommandListener listener) { final ViewController toRemove = stack.peek(); if (size() > 0) backButtonHelper.addToPushedChild(child); child.setParentController(this); stack.push(child.getId(), child); Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions()); addChildToStack(child, child.getView(), resolvedOptions); if (toRemove != null) { if (resolvedOptions.animations.push.enabled.isTrueOrUndefined()) { if (resolvedOptions.animations.push.waitForRender.isTrue()) { child.getView().setAlpha(0); child.setOnAppearedListener(() -> animator.push(child.getView(), resolvedOptions.animations.push, resolvedOptions.transitions, toRemove.getElements(), child.getElements(), () -> { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); })); } else { animator.push(child.getView(), resolvedOptions.animations.push, () -> { if (!toRemove.equals(peek())) { getView().removeView(toRemove.getView()); } listener.onSuccess(child.getId()); }); } } else { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); } } else { listener.onSuccess(child.getId()); } } StackController(Activity activity, List<ViewController> children, ChildControllersRegistry childRegistry, TopBarBackgroundViewController topBarBackgroundViewController, TopBarController topBarController, NavigationAnimator animator, String id, Options initialOptions, BackButtonHelper backButtonHelper, StackPresenter stackPresenter, Presenter presenter); @Override void setDefaultOptions(Options defaultOptions); @Override void onAttachToParent(); @Override void mergeOptions(Options options); @Override void applyChildOptions(Options options, Component child); @Override void mergeChildOptions(Options options, ViewController childController, Component child); @Override void destroy(); @Override void clearOptions(); @Override void onChildDestroyed(Component child); void push(ViewController child, CommandListener listener); void setRoot(ViewController child, CommandListener listener); void pop(Options mergeOptions, CommandListener listener); void popTo(ViewController viewController, Options mergeOptions, CommandListener listener); void popToRoot(Options mergeOptions, CommandListener listener); int size(); boolean isEmpty(); @Override boolean handleBack(CommandListener listener); @Override void sendOnNavigationButtonPressed(String buttonId); @NonNull @Override Collection<ViewController> getChildControllers(); @Override void setupTopTabsWithViewPager(ViewPager viewPager); @Override void clearTopTabs(); @RestrictTo(RestrictTo.Scope.TESTS) TopBar getTopBar(); @RestrictTo(RestrictTo.Scope.TESTS) StackLayout getStackLayout(); }
StackController extends ParentController<StackLayout> { public void push(ViewController child, CommandListener listener) { final ViewController toRemove = stack.peek(); if (size() > 0) backButtonHelper.addToPushedChild(child); child.setParentController(this); stack.push(child.getId(), child); Options resolvedOptions = resolveCurrentOptions(presenter.getDefaultOptions()); addChildToStack(child, child.getView(), resolvedOptions); if (toRemove != null) { if (resolvedOptions.animations.push.enabled.isTrueOrUndefined()) { if (resolvedOptions.animations.push.waitForRender.isTrue()) { child.getView().setAlpha(0); child.setOnAppearedListener(() -> animator.push(child.getView(), resolvedOptions.animations.push, resolvedOptions.transitions, toRemove.getElements(), child.getElements(), () -> { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); })); } else { animator.push(child.getView(), resolvedOptions.animations.push, () -> { if (!toRemove.equals(peek())) { getView().removeView(toRemove.getView()); } listener.onSuccess(child.getId()); }); } } else { getView().removeView(toRemove.getView()); listener.onSuccess(child.getId()); } } else { listener.onSuccess(child.getId()); } } StackController(Activity activity, List<ViewController> children, ChildControllersRegistry childRegistry, TopBarBackgroundViewController topBarBackgroundViewController, TopBarController topBarController, NavigationAnimator animator, String id, Options initialOptions, BackButtonHelper backButtonHelper, StackPresenter stackPresenter, Presenter presenter); @Override void setDefaultOptions(Options defaultOptions); @Override void onAttachToParent(); @Override void mergeOptions(Options options); @Override void applyChildOptions(Options options, Component child); @Override void mergeChildOptions(Options options, ViewController childController, Component child); @Override void destroy(); @Override void clearOptions(); @Override void onChildDestroyed(Component child); void push(ViewController child, CommandListener listener); void setRoot(ViewController child, CommandListener listener); void pop(Options mergeOptions, CommandListener listener); void popTo(ViewController viewController, Options mergeOptions, CommandListener listener); void popToRoot(Options mergeOptions, CommandListener listener); int size(); boolean isEmpty(); @Override boolean handleBack(CommandListener listener); @Override void sendOnNavigationButtonPressed(String buttonId); @NonNull @Override Collection<ViewController> getChildControllers(); @Override void setupTopTabsWithViewPager(ViewPager viewPager); @Override void clearTopTabs(); @RestrictTo(RestrictTo.Scope.TESTS) TopBar getTopBar(); @RestrictTo(RestrictTo.Scope.TESTS) StackLayout getStackLayout();  }