Search in sources :

Example 1 with AssigneesRequestModel

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

the class IssuePagerPresenter method onPutAssignees.

@Override
public void onPutAssignees(@NonNull ArrayList<User> users) {
    AssigneesRequestModel assigneesRequestModel = new AssigneesRequestModel();
    ArrayList<String> assignees = new ArrayList<>();
    Stream.of(users).forEach(userModel -> assignees.add(userModel.getLogin()));
    assigneesRequestModel.setAssignees(assignees.isEmpty() ? Stream.of(issueModel.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), issue -> {
        UsersListModel assignee = new UsersListModel();
        assignee.addAll(users);
        issueModel.setAssignees(assignee);
        manageObservable(issueModel.save(issueModel).toObservable());
        sendToView(view -> updateTimeline(view, R.string.assignee_added));
    });
}
Also used : UsersListModel(com.fastaccess.data.dao.UsersListModel) AssigneesRequestModel(com.fastaccess.data.dao.AssigneesRequestModel) ArrayList(java.util.ArrayList)

Example 2 with AssigneesRequestModel

use of com.fastaccess.data.dao.AssigneesRequestModel 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)

Aggregations

AssigneesRequestModel (com.fastaccess.data.dao.AssigneesRequestModel)2 UsersListModel (com.fastaccess.data.dao.UsersListModel)2 ArrayList (java.util.ArrayList)2 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 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