@Test public void showModal_noAnimation() { disableShowModalAnimation(modal1); CommandListener listener = spy(new CommandListenerAdapter() { @Override public void onSuccess(String childId) { assertThat(modal1.getView().getParent()).isEqualTo(modalsLayout); verify(modal1, times(1)).onViewAppeared(); } }); uut.showModal(modal1, root, listener); verify(animator, times(0)).show( eq(modal1.getView()), eq(modal1.options.animations.showModal), any() ); verify(listener, times(1)).onSuccess(MODAL_ID_1); }
void showModal(ViewController toAdd, ViewController toRemove, CommandListener listener) { if (modalsLayout == null) { listener.onError("Can not show modal before activity is created"); return; } Options options = toAdd.resolveCurrentOptions(defaultOptions); toAdd.setWaitForRender(options.animations.showModal.waitForRender); modalsLayout.addView(toAdd.getView()); if (options.animations.showModal.enabled.isTrueOrUndefined()) { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> animateShow(toAdd, toRemove, listener, options)); } else { animateShow(toAdd, toRemove, listener, options); } } else { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> onShowModalEnd(toAdd, toRemove, listener)); } else { onShowModalEnd(toAdd, toRemove, listener); } } }
ModalPresenter { void showModal(ViewController toAdd, ViewController toRemove, CommandListener listener) { if (modalsLayout == null) { listener.onError("Can not show modal before activity is created"); return; } Options options = toAdd.resolveCurrentOptions(defaultOptions); toAdd.setWaitForRender(options.animations.showModal.waitForRender); modalsLayout.addView(toAdd.getView()); if (options.animations.showModal.enabled.isTrueOrUndefined()) { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> animateShow(toAdd, toRemove, listener, options)); } else { animateShow(toAdd, toRemove, listener, options); } } else { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> onShowModalEnd(toAdd, toRemove, listener)); } else { onShowModalEnd(toAdd, toRemove, listener); } } } }
ModalPresenter { void showModal(ViewController toAdd, ViewController toRemove, CommandListener listener) { if (modalsLayout == null) { listener.onError("Can not show modal before activity is created"); return; } Options options = toAdd.resolveCurrentOptions(defaultOptions); toAdd.setWaitForRender(options.animations.showModal.waitForRender); modalsLayout.addView(toAdd.getView()); if (options.animations.showModal.enabled.isTrueOrUndefined()) { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> animateShow(toAdd, toRemove, listener, options)); } else { animateShow(toAdd, toRemove, listener, options); } } else { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> onShowModalEnd(toAdd, toRemove, listener)); } else { onShowModalEnd(toAdd, toRemove, listener); } } } ModalPresenter(ModalAnimator animator); }
ModalPresenter { void showModal(ViewController toAdd, ViewController toRemove, CommandListener listener) { if (modalsLayout == null) { listener.onError("Can not show modal before activity is created"); return; } Options options = toAdd.resolveCurrentOptions(defaultOptions); toAdd.setWaitForRender(options.animations.showModal.waitForRender); modalsLayout.addView(toAdd.getView()); if (options.animations.showModal.enabled.isTrueOrUndefined()) { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> animateShow(toAdd, toRemove, listener, options)); } else { animateShow(toAdd, toRemove, listener, options); } } else { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> onShowModalEnd(toAdd, toRemove, listener)); } else { onShowModalEnd(toAdd, toRemove, listener); } } } ModalPresenter(ModalAnimator animator); void setRootLayout(ViewGroup rootLayout); void setDefaultOptions(Options defaultOptions); }
ModalPresenter { void showModal(ViewController toAdd, ViewController toRemove, CommandListener listener) { if (modalsLayout == null) { listener.onError("Can not show modal before activity is created"); return; } Options options = toAdd.resolveCurrentOptions(defaultOptions); toAdd.setWaitForRender(options.animations.showModal.waitForRender); modalsLayout.addView(toAdd.getView()); if (options.animations.showModal.enabled.isTrueOrUndefined()) { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> animateShow(toAdd, toRemove, listener, options)); } else { animateShow(toAdd, toRemove, listener, options); } } else { if (options.animations.showModal.waitForRender.isTrue()) { toAdd.setOnAppearedListener(() -> onShowModalEnd(toAdd, toRemove, listener)); } else { onShowModalEnd(toAdd, toRemove, listener); } } } ModalPresenter(ModalAnimator animator); void setRootLayout(ViewGroup rootLayout); void setDefaultOptions(Options defaultOptions);  }