Search in sources :

Example 1 with MergeRequestModel

use of com.fastaccess.data.dao.MergeRequestModel in project FastHub by k0shk0sh.

the class PullRequestPagerPresenter method onMerge.

@Override
public void onMerge(@NonNull String msg, @NonNull String mergeMethod) {
    if (isMergeable() && (isCollaborator() || isRepoOwner())) {
        // double the checking
        if (getPullRequest() == null || getPullRequest().getHead() == null || getPullRequest().getHead().getSha() == null)
            return;
        MergeRequestModel mergeRequestModel = new MergeRequestModel();
        mergeRequestModel.setSha(getPullRequest().getHead().getSha());
        mergeRequestModel.setCommitMessage(msg);
        mergeRequestModel.setMergeMethod(mergeMethod.toLowerCase());
        manageDisposable(RxHelper.getObservable(RestProvider.getPullRequestService(isEnterprise()).mergePullRequest(login, repoId, issueNumber, mergeRequestModel)).doOnSubscribe(disposable -> sendToView(view -> view.showProgress(0))).subscribe(mergeResponseModel -> {
            if (mergeResponseModel.isMerged()) {
                pullRequest.setMerged(true);
                sendToView(view -> updateTimeline(view, R.string.success_merge));
            } else {
                sendToView(view -> view.showErrorMessage(mergeResponseModel.getMessage()));
            }
        }, throwable -> sendToView(view -> view.showErrorMessage(throwable.getMessage()))));
    }
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Stream(com.annimon.stream.Stream) IssueRequestModel(com.fastaccess.data.dao.IssueRequestModel) IssueState(com.fastaccess.data.dao.types.IssueState) InputHelper(com.fastaccess.helper.InputHelper) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) Response(retrofit2.Response) ArrayList(java.util.ArrayList) RxHelper(com.fastaccess.helper.RxHelper) MilestoneModel(com.fastaccess.data.dao.MilestoneModel) LabelListModel(com.fastaccess.data.dao.LabelListModel) PinnedPullRequests(com.fastaccess.data.dao.model.PinnedPullRequests) Observable(io.reactivex.Observable) User(com.fastaccess.data.dao.model.User) BasePresenter(com.fastaccess.ui.base.mvp.presenter.BasePresenter) BundleConstant(com.fastaccess.helper.BundleConstant) CommentRequestModel(com.fastaccess.data.dao.CommentRequestModel) Login(com.fastaccess.data.dao.model.Login) RestProvider(com.fastaccess.provider.rest.RestProvider) Collectors(com.annimon.stream.Collectors) BaseMvp(com.fastaccess.ui.base.mvp.BaseMvp) IssueService(com.fastaccess.data.service.IssueService) AssigneesRequestModel(com.fastaccess.data.dao.AssigneesRequestModel) NotificationSubscriptionBodyModel(com.fastaccess.data.dao.NotificationSubscriptionBodyModel) LabelModel(com.fastaccess.data.dao.LabelModel) TextUtils(android.text.TextUtils) PullsIssuesParser(com.fastaccess.data.dao.PullsIssuesParser) SpannableBuilder(com.fastaccess.ui.widgets.SpannableBuilder) LockIssuePrModel(com.fastaccess.data.dao.LockIssuePrModel) PullRequest(com.fastaccess.data.dao.model.PullRequest) R(com.fastaccess.R) UsersListModel(com.fastaccess.data.dao.UsersListModel) Nullable(android.support.annotation.Nullable) MergeRequestModel(com.fastaccess.data.dao.MergeRequestModel) MergeRequestModel(com.fastaccess.data.dao.MergeRequestModel)

Aggregations

Context (android.content.Context)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 TextUtils (android.text.TextUtils)1 Collectors (com.annimon.stream.Collectors)1 Stream (com.annimon.stream.Stream)1 R (com.fastaccess.R)1 AssigneesRequestModel (com.fastaccess.data.dao.AssigneesRequestModel)1 CommentRequestModel (com.fastaccess.data.dao.CommentRequestModel)1 IssueRequestModel (com.fastaccess.data.dao.IssueRequestModel)1 LabelListModel (com.fastaccess.data.dao.LabelListModel)1 LabelModel (com.fastaccess.data.dao.LabelModel)1 LockIssuePrModel (com.fastaccess.data.dao.LockIssuePrModel)1 MergeRequestModel (com.fastaccess.data.dao.MergeRequestModel)1 MilestoneModel (com.fastaccess.data.dao.MilestoneModel)1 NotificationSubscriptionBodyModel (com.fastaccess.data.dao.NotificationSubscriptionBodyModel)1 PullsIssuesParser (com.fastaccess.data.dao.PullsIssuesParser)1 UsersListModel (com.fastaccess.data.dao.UsersListModel)1