@Test public synchronized void pop() { disablePushAnimation(child1, child2); uut.push(child1, new CommandListenerAdapter()); uut.push(child2, new CommandListenerAdapter() { @Override public void onSuccess(String childId) { assertContainsOnlyId(child2.getId(), child1.getId()); uut.pop(Options.EMPTY, new CommandListenerAdapter()); assertContainsOnlyId(child1.getId()); } }); }
public void pop(Options mergeOptions, CommandListener listener) { if (!canPop()) { listener.onError("Nothing to pop"); return; } peek().mergeOptions(mergeOptions); Options disappearingOptions = resolveCurrentOptions(presenter.getDefaultOptions()); final ViewController disappearing = stack.pop(); final ViewController appearing = stack.peek(); disappearing.onViewWillDisappear(); appearing.onViewWillAppear(); Options resolvedOptions = resolveCurrentOptions(); ViewGroup appearingView = appearing.getView(); if (appearingView.getLayoutParams() == null) { appearingView.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); presenter.applyLayoutParamsOptions(resolvedOptions, appearingView); } if (appearingView.getParent() == null) { getView().addView(appearingView, 0); } presenter.onChildWillAppear(appearing.options, disappearing.options); if (disappearingOptions.animations.pop.enabled.isTrueOrUndefined()) { animator.pop(disappearing.getView(), disappearingOptions.animations.pop, () -> finishPopping(disappearing, listener)); } else { finishPopping(disappearing, listener); } }
StackController extends ParentController<StackLayout> { public void pop(Options mergeOptions, CommandListener listener) { if (!canPop()) { listener.onError("Nothing to pop"); return; } peek().mergeOptions(mergeOptions); Options disappearingOptions = resolveCurrentOptions(presenter.getDefaultOptions()); final ViewController disappearing = stack.pop(); final ViewController appearing = stack.peek(); disappearing.onViewWillDisappear(); appearing.onViewWillAppear(); Options resolvedOptions = resolveCurrentOptions(); ViewGroup appearingView = appearing.getView(); if (appearingView.getLayoutParams() == null) { appearingView.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); presenter.applyLayoutParamsOptions(resolvedOptions, appearingView); } if (appearingView.getParent() == null) { getView().addView(appearingView, 0); } presenter.onChildWillAppear(appearing.options, disappearing.options); if (disappearingOptions.animations.pop.enabled.isTrueOrUndefined()) { animator.pop(disappearing.getView(), disappearingOptions.animations.pop, () -> finishPopping(disappearing, listener)); } else { finishPopping(disappearing, listener); } } }
StackController extends ParentController<StackLayout> { public void pop(Options mergeOptions, CommandListener listener) { if (!canPop()) { listener.onError("Nothing to pop"); return; } peek().mergeOptions(mergeOptions); Options disappearingOptions = resolveCurrentOptions(presenter.getDefaultOptions()); final ViewController disappearing = stack.pop(); final ViewController appearing = stack.peek(); disappearing.onViewWillDisappear(); appearing.onViewWillAppear(); Options resolvedOptions = resolveCurrentOptions(); ViewGroup appearingView = appearing.getView(); if (appearingView.getLayoutParams() == null) { appearingView.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); presenter.applyLayoutParamsOptions(resolvedOptions, appearingView); } if (appearingView.getParent() == null) { getView().addView(appearingView, 0); } presenter.onChildWillAppear(appearing.options, disappearing.options); if (disappearingOptions.animations.pop.enabled.isTrueOrUndefined()) { animator.pop(disappearing.getView(), disappearingOptions.animations.pop, () -> finishPopping(disappearing, listener)); } else { finishPopping(disappearing, listener); } } 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 pop(Options mergeOptions, CommandListener listener) { if (!canPop()) { listener.onError("Nothing to pop"); return; } peek().mergeOptions(mergeOptions); Options disappearingOptions = resolveCurrentOptions(presenter.getDefaultOptions()); final ViewController disappearing = stack.pop(); final ViewController appearing = stack.peek(); disappearing.onViewWillDisappear(); appearing.onViewWillAppear(); Options resolvedOptions = resolveCurrentOptions(); ViewGroup appearingView = appearing.getView(); if (appearingView.getLayoutParams() == null) { appearingView.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); presenter.applyLayoutParamsOptions(resolvedOptions, appearingView); } if (appearingView.getParent() == null) { getView().addView(appearingView, 0); } presenter.onChildWillAppear(appearing.options, disappearing.options); if (disappearingOptions.animations.pop.enabled.isTrueOrUndefined()) { animator.pop(disappearing.getView(), disappearingOptions.animations.pop, () -> finishPopping(disappearing, listener)); } else { finishPopping(disappearing, listener); } } 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 pop(Options mergeOptions, CommandListener listener) { if (!canPop()) { listener.onError("Nothing to pop"); return; } peek().mergeOptions(mergeOptions); Options disappearingOptions = resolveCurrentOptions(presenter.getDefaultOptions()); final ViewController disappearing = stack.pop(); final ViewController appearing = stack.peek(); disappearing.onViewWillDisappear(); appearing.onViewWillAppear(); Options resolvedOptions = resolveCurrentOptions(); ViewGroup appearingView = appearing.getView(); if (appearingView.getLayoutParams() == null) { appearingView.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); presenter.applyLayoutParamsOptions(resolvedOptions, appearingView); } if (appearingView.getParent() == null) { getView().addView(appearingView, 0); } presenter.onChildWillAppear(appearing.options, disappearing.options); if (disappearingOptions.animations.pop.enabled.isTrueOrUndefined()) { animator.pop(disappearing.getView(), disappearingOptions.animations.pop, () -> finishPopping(disappearing, listener)); } else { finishPopping(disappearing, listener); } } 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();  }