use of uk.ivanc.archimvp.ArchiApplication in project archi by ivacf.
the class MainPresenter method loadRepositories.
public void loadRepositories(String usernameEntered) {
String username = usernameEntered.trim();
if (username.isEmpty())
return;
mainMvpView.showProgressIndicator();
if (subscription != null)
subscription.unsubscribe();
ArchiApplication application = ArchiApplication.get(mainMvpView.getContext());
GithubService githubService = application.getGithubService();
subscription = githubService.publicRepositories(username).observeOn(AndroidSchedulers.mainThread()).subscribeOn(application.defaultSubscribeScheduler()).subscribe(new Subscriber<List<Repository>>() {
@Override
public void onCompleted() {
Log.i(TAG, "Repos loaded " + repositories);
if (!repositories.isEmpty()) {
mainMvpView.showRepositories(repositories);
} else {
mainMvpView.showMessage(R.string.text_empty_repos);
}
}
@Override
public void onError(Throwable error) {
Log.e(TAG, "Error loading GitHub repos ", error);
if (isHttp404(error)) {
mainMvpView.showMessage(R.string.error_username_not_found);
} else {
mainMvpView.showMessage(R.string.error_loading_repos);
}
}
@Override
public void onNext(List<Repository> repositories) {
MainPresenter.this.repositories = repositories;
}
});
}
use of uk.ivanc.archimvp.ArchiApplication in project archi by ivacf.
the class RepositoryPresenter method loadOwner.
public void loadOwner(String userUrl) {
ArchiApplication application = ArchiApplication.get(repositoryMvpView.getContext());
GithubService githubService = application.getGithubService();
subscription = githubService.userFromUrl(userUrl).observeOn(AndroidSchedulers.mainThread()).subscribeOn(application.defaultSubscribeScheduler()).subscribe(new Action1<User>() {
@Override
public void call(User user) {
Log.i(TAG, "Full user data loaded " + user);
repositoryMvpView.showOwner(user);
}
});
}
Aggregations