use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class IssueFragmentBase method addReaction.
@Override
public Single<Reaction> addReaction(ReactionBar.Item item, String content) {
ReactionService service = ServiceFactory.get(ReactionService.class, false);
ReactionRequest request = ReactionRequest.builder().content(content).build();
return service.createIssueReaction(mRepoOwner, mRepoName, mIssue.number(), request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class CommitNoteFragment method deleteComment.
private void deleteComment(long id) {
RepositoryCommentService service = ServiceFactory.get(RepositoryCommentService.class, false);
service.deleteCommitComment(mRepoOwner, mRepoName, id).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(getBaseActivity(), R.string.deleting_msg, R.string.error_delete_comment)).subscribe(result -> refreshComments(), error -> handleActionFailure("Deleting comment failed", error));
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class ReviewFragment method onEditorDoSend.
@Override
public Single<?> onEditorDoSend(String comment) {
PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
CreateReviewComment request = CreateReviewComment.builder().body(comment).inReplyTo(mSelectedReplyCommentId).build();
return service.createReviewComment(mRepoOwner, mRepoName, mIssueNumber, request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class ReviewFragment method handleDeleteComment.
private void handleDeleteComment(GitHubCommentBase comment) {
final Single<Response<Void>> responseSingle;
if (comment instanceof ReviewComment) {
PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
responseSingle = service.deleteComment(mRepoOwner, mRepoName, comment.id());
} else {
IssueCommentService service = ServiceFactory.get(IssueCommentService.class, false);
responseSingle = service.deleteIssueComment(mRepoOwner, mRepoName, comment.id());
}
responseSingle.map(ApiHelpers::mapToBooleanOrThrowOnFailure).compose(RxUtils.wrapForBackgroundTask(getBaseActivity(), R.string.deleting_msg, R.string.error_delete_comment)).subscribe(result -> reloadComments(false), error -> handleActionFailure("Deleting comment failed", error));
}
use of com.gh4a.utils.ApiHelpers 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);
}
Aggregations