@Test public void showModal_animatesByDefault() { uut.showModal(modal1, null, new CommandListenerAdapter() { @Override public void onSuccess(String childId) { verify(animator, times(1)).show( eq(modal1.getView()), eq(modal1.options.animations.showModal), any() ); assertThat(animator.isRunning()).isFalse(); } }); }
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);  }