Search in sources :

Example 11 with PullRequest

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

the class PullRequestPagerActivity method addPrReview.

private void addPrReview(@NonNull View view) {
    PullRequest pullRequest = getPresenter().getPullRequest();
    if (pullRequest == null)
        return;
    User author = pullRequest.getUser() != null ? pullRequest.getUser() : pullRequest.getHead() != null && pullRequest.getHead().getAuthor() != null ? pullRequest.getHead().getAuthor() : pullRequest.getUser();
    if (author == null)
        return;
    ReviewRequestModel requestModel = new ReviewRequestModel();
    requestModel.setComments(getPresenter().getCommitComment().isEmpty() ? null : getPresenter().getCommitComment());
    requestModel.setCommitId(pullRequest.getHead().getSha());
    boolean isAuthor = Login.getUser().getLogin().equalsIgnoreCase(author.getLogin());
    ReviewChangesActivity.Companion.startForResult(requestModel, getPresenter().getRepoId(), getPresenter().getLogin(), pullRequest.getNumber(), isAuthor, isEnterprise(), pullRequest.isMerged() || pullRequest.getState() == IssueState.closed).show(getSupportFragmentManager(), ReviewChangesActivity.class.getSimpleName());
}
Also used : User(com.fastaccess.data.dao.model.User) ReviewChangesActivity(com.fastaccess.ui.modules.reviews.changes.ReviewChangesActivity) PullRequest(com.fastaccess.data.dao.model.PullRequest) ReviewRequestModel(com.fastaccess.data.dao.ReviewRequestModel)

Example 12 with PullRequest

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

the class PullRequestPagerActivity method onSetupIssue.

@Override
public void onSetupIssue(boolean update) {
    hideProgress();
    if (getPresenter().getPullRequest() == null) {
        return;
    }
    invalidateOptionsMenu();
    PullRequest pullRequest = getPresenter().getPullRequest();
    setTaskName(pullRequest.getRepoId() + " - " + pullRequest.getTitle());
    updateViews(pullRequest);
    if (update) {
        PullRequestTimelineFragment issueDetailsView = getPullRequestTimelineFragment();
        if (issueDetailsView != null && getPresenter().getPullRequest() != null) {
            issueDetailsView.onUpdateHeader();
        }
    } else {
        if (pager.getAdapter() == null) {
            pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForPullRequest(this, pullRequest)));
            tabs.setupWithViewPager(pager);
            tabs.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager) {

                @Override
                public void onTabReselected(TabLayout.Tab tab) {
                    super.onTabReselected(tab);
                    onScrollTop(tab.getPosition());
                }
            });
        } else {
            onUpdateTimeline();
        }
    }
    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            hideShowFab();
            super.onPageSelected(position);
        }
    });
    initTabs(pullRequest);
    hideShowFab();
    AnimHelper.mimicFabVisibility(getPresenter().hasReviewComments(), prReviewHolder, null);
    reviewsCount.setText(String.format("%s", getPresenter().getCommitComment().size()));
}
Also used : FragmentsPagerAdapter(com.fastaccess.ui.adapter.FragmentsPagerAdapter) TabLayout(android.support.design.widget.TabLayout) PullRequest(com.fastaccess.data.dao.model.PullRequest) PullRequestTimelineFragment(com.fastaccess.ui.modules.repos.pull_requests.pull_request.details.timeline.timeline.PullRequestTimelineFragment) ViewPager(android.support.v4.view.ViewPager)

Example 13 with PullRequest

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

the class PullRequestPagerPresenter method onPutAssignees.

@Override
public void onPutAssignees(@NonNull ArrayList<User> users, boolean isAssignees) {
    AssigneesRequestModel assigneesRequestModel = new AssigneesRequestModel();
    ArrayList<String> assignees = Stream.of(users).map(User::getLogin).collect(Collectors.toCollection(ArrayList::new));
    if (isAssignees) {
        assigneesRequestModel.setAssignees(assignees.isEmpty() ? Stream.of(pullRequest.getAssignees()).map(User::getLogin).toList() : assignees);
        makeRestCall(!assignees.isEmpty() ? RestProvider.getIssueService(isEnterprise()).putAssignees(login, repoId, issueNumber, assigneesRequestModel) : RestProvider.getIssueService(isEnterprise()).deleteAssignees(login, repoId, issueNumber, assigneesRequestModel), pullRequestResponse -> {
            UsersListModel usersListModel = new UsersListModel();
            usersListModel.addAll(users);
            this.pullRequest.setAssignees(usersListModel);
            manageObservable(pullRequest.save(pullRequest).toObservable());
            sendToView(view -> updateTimeline(view, R.string.assignee_added));
        });
    } else {
        assigneesRequestModel.setReviewers(assignees);
        makeRestCall(RestProvider.getPullRequestService(isEnterprise()).putReviewers(login, repoId, issueNumber, assigneesRequestModel), pullRequestResponse -> sendToView(view -> updateTimeline(view, R.string.reviewer_added)));
    }
}
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) UsersListModel(com.fastaccess.data.dao.UsersListModel) AssigneesRequestModel(com.fastaccess.data.dao.AssigneesRequestModel)

Example 14 with PullRequest

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

the class PullRequestPagerPresenter method onLockUnlockConversations.

@Override
public void onLockUnlockConversations(String reason) {
    PullRequest currentPullRequest = getPullRequest();
    if (currentPullRequest == null)
        return;
    IssueService service = RestProvider.getIssueService(isEnterprise());
    LockIssuePrModel model = null;
    if (!isLocked() && !InputHelper.isEmpty(reason)) {
        model = new LockIssuePrModel(true, reason);
    }
    Observable<Response<Boolean>> observable = RxHelper.getObservable(model == null ? service.unlockIssue(login, repoId, issueNumber) : service.lockIssue(model, login, repoId, issueNumber));
    makeRestCall(observable, booleanResponse -> {
        int code = booleanResponse.code();
        if (code == 204) {
            pullRequest.setLocked(!isLocked());
            sendToView(view -> view.onSetupIssue(false));
        }
    });
}
Also used : IssueService(com.fastaccess.data.service.IssueService) Response(retrofit2.Response) PullRequest(com.fastaccess.data.dao.model.PullRequest) LockIssuePrModel(com.fastaccess.data.dao.LockIssuePrModel)

Example 15 with PullRequest

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

the class PullRequestFilesFragment method setupChanges.

private void setupChanges() {
    PullRequest pullRequest = issueCallback.getData();
    if (pullRequest != null) {
        addition.setText(String.valueOf(pullRequest.getAdditions()));
        deletion.setText(String.valueOf(pullRequest.getDeletions()));
        changes.setText(String.valueOf(pullRequest.getChangedFiles()));
    }
}
Also used : PullRequest(com.fastaccess.data.dao.model.PullRequest)

Aggregations

PullRequest (com.fastaccess.data.dao.model.PullRequest)20 Bundle (android.os.Bundle)7 NonNull (android.support.annotation.NonNull)6 Nullable (android.support.annotation.Nullable)6 R (com.fastaccess.R)6 Login (com.fastaccess.data.dao.model.Login)6 BundleConstant (com.fastaccess.helper.BundleConstant)6 InputHelper (com.fastaccess.helper.InputHelper)6 RxHelper (com.fastaccess.helper.RxHelper)6 RestProvider (com.fastaccess.provider.rest.RestProvider)6 BaseMvp (com.fastaccess.ui.base.mvp.BaseMvp)6 BasePresenter (com.fastaccess.ui.base.mvp.presenter.BasePresenter)6 Observable (io.reactivex.Observable)6 ArrayList (java.util.ArrayList)6 Activity (android.app.Activity)5 CommentRequestModel (com.fastaccess.data.dao.CommentRequestModel)5 Comment (com.fastaccess.data.dao.model.Comment)5 PopupMenu (android.widget.PopupMenu)4 EditReviewCommentModel (com.fastaccess.data.dao.EditReviewCommentModel)4 GroupedReviewModel (com.fastaccess.data.dao.GroupedReviewModel)4