use of com.meisolsson.githubsdk.service.users.UserFollowerService in project PocketHub by pockethub.
the class UserViewActivity method followUser.
private void followUser() {
UserFollowerService service = ServiceGenerator.createService(this, UserFollowerService.class);
Single<Response<Void>> followSingle;
if (isFollowing) {
followSingle = service.unfollowUser(user.login());
} else {
followSingle = service.followUser(user.login());
}
followSingle.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(aVoid -> isFollowing = !isFollowing, e -> ToastUtils.show(this, isFollowing ? R.string.error_unfollowing_person : R.string.error_following_person));
}
use of com.meisolsson.githubsdk.service.users.UserFollowerService in project gh4a by slapperwan.
the class UserFragment method loadIsFollowingStateIfNeeded.
private void loadIsFollowingStateIfNeeded(boolean force) {
if (mIsSelf || !Gh4Application.get().isAuthorized()) {
return;
}
UserFollowerService service = ServiceFactory.get(UserFollowerService.class, force);
service.isFollowing(mUser.login()).map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(makeLoaderSingle(ID_LOADER_IS_FOLLOWING, force)).subscribe(result -> {
mIsFollowing = result;
getActivity().invalidateOptionsMenu();
}, this::handleLoadFailure);
}
use of com.meisolsson.githubsdk.service.users.UserFollowerService in project gh4a by slapperwan.
the class UserFragment method toggleFollowingState.
private void toggleFollowingState() {
UserFollowerService service = ServiceFactory.get(UserFollowerService.class, false);
Single<Response<Void>> responseSingle = mIsFollowing ? service.unfollowUser(mUser.login()) : service.followUser(mUser.login());
responseSingle.map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(RxUtils::doInBackground).subscribe(result -> {
mIsFollowing = !mIsFollowing;
updateFollowingAction();
getActivity().invalidateOptionsMenu();
}, error -> {
handleActionFailure("Toggling following state failed", error);
getActivity().invalidateOptionsMenu();
});
}
Aggregations