Search in sources :

Example 26 with ApiHelpers

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);
}
Also used : ReactionRequest(com.meisolsson.githubsdk.model.request.ReactionRequest) ReactionService(com.meisolsson.githubsdk.service.reactions.ReactionService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 27 with ApiHelpers

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));
}
Also used : ApiHelpers(com.gh4a.utils.ApiHelpers) RepositoryCommentService(com.meisolsson.githubsdk.service.repositories.RepositoryCommentService)

Example 28 with ApiHelpers

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);
}
Also used : ApiHelpers(com.gh4a.utils.ApiHelpers) CreateReviewComment(com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)

Example 29 with ApiHelpers

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));
}
Also used : Response(retrofit2.Response) IssueCommentService(com.meisolsson.githubsdk.service.issues.IssueCommentService) CreateReviewComment(com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment) ReviewComment(com.meisolsson.githubsdk.model.ReviewComment) ApiHelpers(com.gh4a.utils.ApiHelpers) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)

Example 30 with ApiHelpers

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);
}
Also used : UserFollowerService(com.meisolsson.githubsdk.service.users.UserFollowerService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)68 Response (retrofit2.Response)13 RxUtils (com.gh4a.utils.RxUtils)12 ServiceFactory (com.gh4a.ServiceFactory)11 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 Optional (com.gh4a.utils.Optional)10 PullRequestReviewCommentService (com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)10 Single (io.reactivex.Single)9 Context (android.content.Context)7 LayoutInflater (android.view.LayoutInflater)7 CommentRequest (com.meisolsson.githubsdk.model.request.CommentRequest)7 List (java.util.List)7 View (android.view.View)6 R (com.gh4a.R)6 IntentUtils (com.gh4a.utils.IntentUtils)6 User (com.meisolsson.githubsdk.model.User)6 ReactionRequest (com.meisolsson.githubsdk.model.request.ReactionRequest)6 CreateReviewComment (com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment)6 ReactionService (com.meisolsson.githubsdk.service.reactions.ReactionService)6