Search in sources :

Example 6 with PullRequestService

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

the class PullRequestActivity method mergePullRequest.

private void mergePullRequest(String commitMessage, MergeRequest.Method mergeMethod) {
    String errorMessage = getString(R.string.pull_error_merge, mPullRequest.number());
    PullRequestService service = ServiceFactory.get(PullRequestService.class, false);
    MergeRequest request = MergeRequest.builder().commitMessage(commitMessage).method(mergeMethod).build();
    service.mergePullRequest(mRepoOwner, mRepoName, mPullRequestNumber, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.merging_msg, errorMessage)).subscribe(result -> {
        if (result.merged()) {
            mPullRequest = mPullRequest.toBuilder().merged(true).state(IssueState.Closed).build();
        }
        handlePullRequestUpdate();
    }, error -> handleActionFailure("Merging pull request failed", error));
}
Also used : PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) MergeRequest(com.meisolsson.githubsdk.model.request.pull_request.MergeRequest) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 7 with PullRequestService

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

the class PullRequestActivity method load.

private void load(boolean force) {
    PullRequestService prService = ServiceFactory.get(PullRequestService.class, force);
    IssueService issueService = ServiceFactory.get(IssueService.class, force);
    Single<PullRequest> prSingle = prService.getPullRequest(mRepoOwner, mRepoName, mPullRequestNumber).map(ApiHelpers::throwOnFailure);
    Single<Issue> issueSingle = issueService.getIssue(mRepoOwner, mRepoName, mPullRequestNumber).map(ApiHelpers::throwOnFailure);
    Single<Boolean> isCollaboratorSingle = SingleFactory.isAppUserRepoCollaborator(mRepoOwner, mRepoName, force);
    Single.zip(issueSingle, prSingle, isCollaboratorSingle, Triplet::create).compose(makeLoaderSingle(0, force)).subscribe(result -> {
        mIssue = result.first;
        mPullRequest = result.second;
        mIsCollaborator = result.third;
        fillHeader();
        setContentShown(true);
        invalidateTabs();
        updateFabVisibility();
        supportInvalidateOptionsMenu();
        if (mInitialPage >= 0 && mInitialPage < TITLES.length) {
            getPager().setCurrentItem(mInitialPage);
            mInitialPage = -1;
        }
    }, this::handleLoadFailure);
}
Also used : PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) IssueService(com.meisolsson.githubsdk.service.issues.IssueService) Issue(com.meisolsson.githubsdk.model.Issue) Triplet(com.gh4a.utils.Triplet) PullRequest(com.meisolsson.githubsdk.model.PullRequest) EditPullRequest(com.meisolsson.githubsdk.model.request.pull_request.EditPullRequest) ApiHelpers(com.gh4a.utils.ApiHelpers)

Aggregations

PullRequestService (com.meisolsson.githubsdk.service.pull_request.PullRequestService)7 ApiHelpers (com.gh4a.utils.ApiHelpers)6 Intent (android.content.Intent)3 ServiceFactory (com.gh4a.ServiceFactory)3 IntentUtils (com.gh4a.utils.IntentUtils)3 Optional (com.gh4a.utils.Optional)3 RxUtils (com.gh4a.utils.RxUtils)3 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)3 PullRequest (com.meisolsson.githubsdk.model.PullRequest)3 ReviewComment (com.meisolsson.githubsdk.model.ReviewComment)3 PullRequestReviewCommentService (com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)3 Single (io.reactivex.Single)3 List (java.util.List)3 Bundle (android.os.Bundle)2 StringRes (android.support.annotation.StringRes)2 AlertDialog (android.support.v7.app.AlertDialog)2 View (android.view.View)2 R (com.gh4a.R)2 EditIssueCommentActivity (com.gh4a.activities.EditIssueCommentActivity)2 EditPullRequestCommentActivity (com.gh4a.activities.EditPullRequestCommentActivity)2