Search in sources :

Example 16 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class IssueLabelListActivity method deleteLabel.

private void deleteLabel(IssueLabelAdapter.EditableLabel label) {
    String errorMessage = getString(R.string.issue_error_delete_label, label.base().name());
    IssueLabelService service = ServiceFactory.get(IssueLabelService.class, false);
    service.deleteLabel(mRepoOwner, mRepoName, label.base().name()).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.deleting_msg, errorMessage)).subscribe(result -> {
        loadLabels(true);
        setResult(RESULT_OK);
    }, error -> handleActionFailure("Deleting label failed", error));
}
Also used : IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 17 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class EditCommitCommentActivity method editComment.

@Override
protected Single<GitHubCommentBase> editComment(String repoOwner, String repoName, long commentId, String body) {
    RepositoryCommentService service = ServiceFactory.get(RepositoryCommentService.class, false);
    CommentRequest request = CommentRequest.builder().body(body).build();
    return service.editCommitComment(repoOwner, repoName, commentId, request).map(ApiHelpers::throwOnFailure);
}
Also used : CommentRequest(com.meisolsson.githubsdk.model.request.CommentRequest) ApiHelpers(com.gh4a.utils.ApiHelpers) RepositoryCommentService(com.meisolsson.githubsdk.service.repositories.RepositoryCommentService)

Example 18 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class EditCommitCommentActivity method createComment.

@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
    RepositoryCommentService service = ServiceFactory.get(RepositoryCommentService.class, false);
    CreateCommitComment request = CreateCommitComment.builder().body(body).build();
    String sha = getIntent().getStringExtra("commit");
    return service.createCommitComment(repoOwner, repoName, sha, request).map(ApiHelpers::throwOnFailure);
}
Also used : ApiHelpers(com.gh4a.utils.ApiHelpers) RepositoryCommentService(com.meisolsson.githubsdk.service.repositories.RepositoryCommentService) CreateCommitComment(com.meisolsson.githubsdk.model.request.repository.CreateCommitComment)

Example 19 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class EditIssueCommentActivity method editComment.

@Override
protected Single<GitHubCommentBase> editComment(String repoOwner, String repoName, long commentId, String body) {
    IssueCommentService service = ServiceFactory.get(IssueCommentService.class, false);
    CommentRequest request = CommentRequest.builder().body(body).build();
    return service.editIssueComment(repoOwner, repoName, commentId, request).map(ApiHelpers::throwOnFailure);
}
Also used : CommentRequest(com.meisolsson.githubsdk.model.request.CommentRequest) IssueCommentService(com.meisolsson.githubsdk.service.issues.IssueCommentService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 20 with ApiHelpers

use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.

the class CreateReviewActivity method onEditorDoSend.

@Override
public Single<?> onEditorDoSend(String body) {
    int position = mReviewEventSpinner.getSelectedItemPosition();
    @SuppressWarnings("ConstantConditions") ReviewEventDesc desc = mReviewEventAdapter.getItem(position);
    PullRequestReviewService service = ServiceFactory.get(PullRequestReviewService.class, false);
    final Single<Response<Review>> resultSingle;
    if (mPendingReview == null) {
        CreateReview request = CreateReview.builder().body(body).event(desc.mCreateEvent).build();
        resultSingle = service.createReview(mRepoOwner, mRepoName, mPullRequestNumber, request);
    } else {
        SubmitReview request = SubmitReview.builder().body(body).event(desc.mSubmitEvent).build();
        resultSingle = service.submitReview(mRepoOwner, mRepoName, mPullRequestNumber, mPendingReview.id(), request);
    }
    return resultSingle.map(ApiHelpers::throwOnFailure);
}
Also used : Response(retrofit2.Response) SubmitReview(com.meisolsson.githubsdk.model.request.pull_request.SubmitReview) ApiHelpers(com.gh4a.utils.ApiHelpers) CreateReview(com.meisolsson.githubsdk.model.request.pull_request.CreateReview) PullRequestReviewService(com.meisolsson.githubsdk.service.pull_request.PullRequestReviewService)

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