Search in sources :

Example 1 with EditPullRequest

use of com.meisolsson.githubsdk.model.request.pull_request.EditPullRequest in project gh4a by slapperwan.

the class PullRequestActivity method updatePullRequestState.

private void updatePullRequestState(boolean open) {
    @StringRes int dialogMessageResId = open ? R.string.opening_msg : R.string.closing_msg;
    @StringRes int errorMessageResId = open ? R.string.issue_error_reopen : R.string.issue_error_close;
    String errorMessage = getString(errorMessageResId, mPullRequest.number());
    PullRequestService service = ServiceFactory.get(PullRequestService.class, false);
    EditPullRequest request = EditPullRequest.builder().state(open ? ApiHelpers.IssueState.OPEN : ApiHelpers.IssueState.CLOSED).build();
    service.editPullRequest(mRepoOwner, mRepoName, mPullRequestNumber, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, dialogMessageResId, errorMessage)).subscribe(result -> {
        mPullRequest = result;
        handlePullRequestUpdate();
    }, error -> handleActionFailure("Updating pull request failed", error));
}
Also used : PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) EditPullRequest(com.meisolsson.githubsdk.model.request.pull_request.EditPullRequest) StringRes(android.support.annotation.StringRes) ApiHelpers(com.gh4a.utils.ApiHelpers)

Aggregations

StringRes (android.support.annotation.StringRes)1 ApiHelpers (com.gh4a.utils.ApiHelpers)1 EditPullRequest (com.meisolsson.githubsdk.model.request.pull_request.EditPullRequest)1 PullRequestService (com.meisolsson.githubsdk.service.pull_request.PullRequestService)1