use of com.meisolsson.githubsdk.service.activity.StarringService in project PocketHub by pockethub.
the class RepositoryViewActivity method starRepository.
private void starRepository() {
StarringService service = ServiceGenerator.createService(this, StarringService.class);
Single<Response<Boolean>> starSingle;
if (isStarred) {
starSingle = service.unstarRepository(repository.owner().login(), repository.name());
} else {
starSingle = service.starRepository(repository.owner().login(), repository.name());
}
starSingle.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(this.<Response<Boolean>>bindToLifecycle()).subscribe(new ObserverAdapter<Response<Boolean>>() {
@Override
public void onSuccess(Response<Boolean> aBoolean) {
isStarred = !isStarred;
setResult(RESOURCE_CHANGED);
}
@Override
public void onError(Throwable e) {
ToastUtils.show(RepositoryViewActivity.this, isStarred ? R.string.error_unstarring_repository : R.string.error_starring_repository);
}
});
}
Aggregations