Search in sources :

Example 1 with StarringService

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);
        }
    });
}
Also used : Response(retrofit2.Response) StarringService(com.meisolsson.githubsdk.service.activity.StarringService)

Aggregations

StarringService (com.meisolsson.githubsdk.service.activity.StarringService)1 Response (retrofit2.Response)1