@Test public void loadContributorsEmpty() throws Exception { ContributorsPresenter contributorsPresenter = new ContributorsPresenter(appRepository); contributorsPresenter.attachView(contributorsView); when(githubApi.contributors(OWNER, REPO)).thenReturn( Observable.just(Response.success(new ArrayList<>()))); contributorsPresenter.loadContributors(OWNER, REPO, PULL_TO_REFRESH); verify(contributorsView).showProgress(PULL_TO_REFRESH); verify(githubApi).contributors(OWNER, REPO); verify(contributorsView).showEmpty(); verifyNoMoreInteractions(contributorsView); verifyNoMoreInteractions(githubApi); }
public void loadContributors(String owner, String repo, boolean pullToRefresh) { if (isViewAttached()) { getView().showProgress(pullToRefresh); } subscription = appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() { @Override public void onCompleted() { Timber.d("Finished loading contributors."); } @Override public void onError(final Throwable e) { if (isViewAttached()) { getView().showError(e.toString()); } } @Override public void onNext(final List<Contributor> contributors) { if (!isViewAttached()) { return; } if (contributors != null && !contributors.isEmpty()) { getView().showContributors(contributors); } else { getView().showEmpty(); } } }); }
ContributorsPresenter extends MvpBasePresenter<ContributorsView> { public void loadContributors(String owner, String repo, boolean pullToRefresh) { if (isViewAttached()) { getView().showProgress(pullToRefresh); } subscription = appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() { @Override public void onCompleted() { Timber.d("Finished loading contributors."); } @Override public void onError(final Throwable e) { if (isViewAttached()) { getView().showError(e.toString()); } } @Override public void onNext(final List<Contributor> contributors) { if (!isViewAttached()) { return; } if (contributors != null && !contributors.isEmpty()) { getView().showContributors(contributors); } else { getView().showEmpty(); } } }); } }
ContributorsPresenter extends MvpBasePresenter<ContributorsView> { public void loadContributors(String owner, String repo, boolean pullToRefresh) { if (isViewAttached()) { getView().showProgress(pullToRefresh); } subscription = appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() { @Override public void onCompleted() { Timber.d("Finished loading contributors."); } @Override public void onError(final Throwable e) { if (isViewAttached()) { getView().showError(e.toString()); } } @Override public void onNext(final List<Contributor> contributors) { if (!isViewAttached()) { return; } if (contributors != null && !contributors.isEmpty()) { getView().showContributors(contributors); } else { getView().showEmpty(); } } }); } ContributorsPresenter(final AppRepository appRepository); }
ContributorsPresenter extends MvpBasePresenter<ContributorsView> { public void loadContributors(String owner, String repo, boolean pullToRefresh) { if (isViewAttached()) { getView().showProgress(pullToRefresh); } subscription = appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() { @Override public void onCompleted() { Timber.d("Finished loading contributors."); } @Override public void onError(final Throwable e) { if (isViewAttached()) { getView().showError(e.toString()); } } @Override public void onNext(final List<Contributor> contributors) { if (!isViewAttached()) { return; } if (contributors != null && !contributors.isEmpty()) { getView().showContributors(contributors); } else { getView().showEmpty(); } } }); } ContributorsPresenter(final AppRepository appRepository); void loadContributors(String owner, String repo, boolean pullToRefresh); @Override void detachView(); }
ContributorsPresenter extends MvpBasePresenter<ContributorsView> { public void loadContributors(String owner, String repo, boolean pullToRefresh) { if (isViewAttached()) { getView().showProgress(pullToRefresh); } subscription = appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() { @Override public void onCompleted() { Timber.d("Finished loading contributors."); } @Override public void onError(final Throwable e) { if (isViewAttached()) { getView().showError(e.toString()); } } @Override public void onNext(final List<Contributor> contributors) { if (!isViewAttached()) { return; } if (contributors != null && !contributors.isEmpty()) { getView().showContributors(contributors); } else { getView().showEmpty(); } } }); } ContributorsPresenter(final AppRepository appRepository); void loadContributors(String owner, String repo, boolean pullToRefresh); @Override void detachView();  }