Search in sources :

Example 11 with User

use of com.fastaccess.data.dao.model.User 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 User

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

the class PullRequestPagerPresenter method isOwner.

@Override
public boolean isOwner() {
    if (getPullRequest() == null)
        return false;
    User userModel = getPullRequest() != null ? getPullRequest().getUser() : null;
    Login me = Login.getUser();
    PullsIssuesParser parser = PullsIssuesParser.getForIssue(getPullRequest().getHtmlUrl());
    return (userModel != null && userModel.getLogin().equalsIgnoreCase(me.getLogin())) || (parser != null && parser.getLogin().equalsIgnoreCase(me.getLogin()));
}
Also used : User(com.fastaccess.data.dao.model.User) Login(com.fastaccess.data.dao.model.Login) PullsIssuesParser(com.fastaccess.data.dao.PullsIssuesParser)

Example 13 with User

use of com.fastaccess.data.dao.model.User 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 User

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

the class CreateIssueActivity method onSelectedAssignees.

@Override
public void onSelectedAssignees(@NonNull ArrayList<User> users, boolean isAssignees) {
    this.users.clear();
    this.users.addAll(users);
    SpannableBuilder builder = SpannableBuilder.builder();
    for (int i = 0; i < users.size(); i++) {
        User user = users.get(i);
        builder.append(user.getLogin());
        if (i != users.size() - 1) {
            builder.append(", ");
        }
    }
    assignee.setText(builder);
}
Also used : User(com.fastaccess.data.dao.model.User) SpannableBuilder(com.fastaccess.ui.widgets.SpannableBuilder)

Example 15 with User

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

the class FeedsViewHolder method appendTeamEvent.

private void appendTeamEvent(SpannableBuilder spannableBuilder, Event eventsModel) {
    TeamsModel teamsModel = eventsModel.getPayload().getTeam();
    User user = eventsModel.getPayload().getUser();
    spannableBuilder.bold("added").append(" ").append(user != null ? user.getLogin() : eventsModel.getRepo().getName()).append(" ").bold("in").append(" ").append(teamsModel.getName() != null ? teamsModel.getName() : teamsModel.getSlug());
}
Also used : TeamsModel(com.fastaccess.data.dao.TeamsModel) User(com.fastaccess.data.dao.model.User)

Aggregations

User (com.fastaccess.data.dao.model.User)15 LabelModel (com.fastaccess.data.dao.LabelModel)4 Login (com.fastaccess.data.dao.model.Login)4 SpannableBuilder (com.fastaccess.ui.widgets.SpannableBuilder)4 NonNull (android.support.annotation.NonNull)3 MilestoneModel (com.fastaccess.data.dao.MilestoneModel)3 PullsIssuesParser (com.fastaccess.data.dao.PullsIssuesParser)3 PullRequest (com.fastaccess.data.dao.model.PullRequest)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 Nullable (android.support.annotation.Nullable)2 Collectors (com.annimon.stream.Collectors)2 Stream (com.annimon.stream.Stream)2 R (com.fastaccess.R)2 IssueRequestModel (com.fastaccess.data.dao.IssueRequestModel)2 LabelListModel (com.fastaccess.data.dao.LabelListModel)2 UsersListModel (com.fastaccess.data.dao.UsersListModel)2 BundleConstant (com.fastaccess.helper.BundleConstant)2 InputHelper (com.fastaccess.helper.InputHelper)2 RxHelper (com.fastaccess.helper.RxHelper)2