Search in sources :

Example 1 with PullRequestReviewCommentService

use of com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService in project gh4a by slapperwan.

the class EditPullRequestCommentActivity method createComment.

@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
    int prNumber = getIntent().getIntExtra("pr", 0);
    PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
    CreateReviewComment request = CreateReviewComment.builder().body(body).inReplyTo(replyToCommentId).build();
    return service.createReviewComment(repoOwner, repoName, prNumber, 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 2 with PullRequestReviewCommentService

use of com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService 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 3 with PullRequestReviewCommentService

use of com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService 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 4 with PullRequestReviewCommentService

use of com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService in project gh4a by slapperwan.

the class PullRequestFilesFragment method loadComments.

private void loadComments(boolean force) {
    final PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, force);
    ApiHelpers.PageIterator.toSingle(page -> service.getPullRequestComments(mRepoOwner, mRepoName, mPullRequestNumber, page)).compose(RxUtils.filter(c -> c.position() != null && c.position() >= 0)).compose(makeLoaderSingle(ID_LOADER_COMMENTS, force)).subscribe(result -> {
        mComments = result;
        populateUiIfReady();
    }, this::handleLoadFailure);
}
Also used : FileUtils(com.gh4a.utils.FileUtils) Bundle(android.os.Bundle) FileViewerActivity(com.gh4a.activities.FileViewerActivity) ApiHelpers(com.gh4a.utils.ApiHelpers) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) ReviewComment(com.meisolsson.githubsdk.model.ReviewComment) Intent(android.content.Intent) PullRequestDiffViewerActivity(com.gh4a.activities.PullRequestDiffViewerActivity) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService) List(java.util.List) RxUtils(com.gh4a.utils.RxUtils) PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) R(com.gh4a.R) View(android.view.View) Nullable(android.support.annotation.Nullable) ServiceFactory(com.gh4a.ServiceFactory) Activity(android.app.Activity) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)

Example 5 with PullRequestReviewCommentService

use of com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService in project gh4a by slapperwan.

the class PullRequestReviewDiffLoadTask method getSingle.

@Override
protected Single<Optional<Intent>> getSingle() {
    final PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
    final PullRequestReviewService reviewService = ServiceFactory.get(PullRequestReviewService.class, false);
    long diffCommentId = Long.parseLong(mDiffId.fileHash);
    return ApiHelpers.PageIterator.toSingle(page -> service.getPullRequestComments(mRepoOwner, mRepoName, mPullRequestNumber, page)).compose(RxUtils.filterAndMapToFirst(c -> c.id() == diffCommentId)).flatMap(commentOpt -> commentOpt.flatMap(comment -> {
        long reviewId = comment.pullRequestReviewId();
        return reviewService.getReview(mRepoOwner, mRepoName, mPullRequestNumber, reviewId).map(ApiHelpers::throwOnFailure);
    })).map(reviewOpt -> reviewOpt.map(review -> ReviewActivity.makeIntent(mActivity, mRepoOwner, mRepoName, mPullRequestNumber, review, new IntentUtils.InitialCommentMarker(diffCommentId))));
}
Also used : PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService) VisibleForTesting(android.support.annotation.VisibleForTesting) ReviewActivity(com.gh4a.activities.ReviewActivity) RxUtils(com.gh4a.utils.RxUtils) PullRequestReviewService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService) ApiHelpers(com.gh4a.utils.ApiHelpers) FragmentActivity(android.support.v4.app.FragmentActivity) Optional(com.gh4a.utils.Optional) Intent(android.content.Intent) ServiceFactory(com.gh4a.ServiceFactory) Single(io.reactivex.Single) IntentUtils(com.gh4a.utils.IntentUtils) IntentUtils(com.gh4a.utils.IntentUtils) ApiHelpers(com.gh4a.utils.ApiHelpers) PullRequestReviewService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService) PullRequestReviewCommentService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)12 PullRequestReviewCommentService (com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)12 Intent (android.content.Intent)6 ServiceFactory (com.gh4a.ServiceFactory)6 RxUtils (com.gh4a.utils.RxUtils)6 ReviewComment (com.meisolsson.githubsdk.model.ReviewComment)6 IntentUtils (com.gh4a.utils.IntentUtils)5 Optional (com.gh4a.utils.Optional)5 CreateReviewComment (com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment)5 Single (io.reactivex.Single)5 Bundle (android.os.Bundle)4 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)4 PullRequestReviewService (com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService)4 PullRequestService (com.meisolsson.githubsdk.service.pull_request.PullRequestService)4 List (java.util.List)4 VisibleForTesting (android.support.annotation.VisibleForTesting)3 FragmentActivity (android.support.v4.app.FragmentActivity)3 View (android.view.View)3 R (com.gh4a.R)3 TimelineItem (com.gh4a.model.TimelineItem)3