-
-
Save BartoszJarocki/822ccd09e836d11d4e1f99c8cf7b9150 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContributorsPresenter extends MvpBasePresenter<ContributorsView> { | |
private AppRepository appRepository; | |
private Subscription subscription; | |
public ContributorsPresenter(final AppRepository appRepository) { | |
this.appRepository = appRepository; | |
} | |
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(); | |
} | |
} | |
}); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment