Search in sources :

Example 1 with PullsIssuesParser

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

the class IssuePopupFragment method showPopup.

public static void showPopup(@NonNull FragmentManager manager, @NonNull Issue issue) {
    IssuePopupFragment fragment = new IssuePopupFragment();
    PullsIssuesParser parser = PullsIssuesParser.getForIssue(issue.getHtmlUrl());
    if (parser == null) {
        parser = PullsIssuesParser.getForPullRequest(issue.getHtmlUrl());
    }
    if (parser == null)
        return;
    fragment.setArguments(getBundle(parser.getLogin(), parser.getRepoId(), issue.getNumber(), issue.getTitle(), issue.getBody(), issue.getUser(), issue.getAssignee(), issue.getLabels(), issue.getMilestone(), !issue.isLocked()));
    fragment.show(manager, "");
}
Also used : PullsIssuesParser(com.fastaccess.data.dao.PullsIssuesParser)

Example 2 with PullsIssuesParser

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

the class IssuePagerPresenter method isOwner.

@Override
public boolean isOwner() {
    if (getIssue() == null)
        return false;
    User userModel = getIssue() != null ? getIssue().getUser() : null;
    Login me = Login.getUser();
    PullsIssuesParser parser = PullsIssuesParser.getForIssue(getIssue().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 3 with PullsIssuesParser

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

the class AbstractPullRequest method getMergeBy.

@NonNull
public static SpannableBuilder getMergeBy(@NonNull PullRequest pullRequest, @NonNull Context context, boolean showRepoName) {
    boolean isMerge = pullRequest.isMerged() || !InputHelper.isEmpty(pullRequest.mergedAt);
    if (isMerge) {
        User merger = pullRequest.getMergedBy();
        SpannableBuilder builder = SpannableBuilder.builder();
        if (showRepoName) {
            PullsIssuesParser parser = PullsIssuesParser.getForPullRequest(pullRequest.getHtmlUrl());
            if (parser != null)
                builder.bold(parser.getLogin()).append("/").bold(parser.getRepoId()).append(" ").bold("#").bold(String.valueOf(pullRequest.getNumber())).append(" ");
        } else {
            builder.bold("#" + pullRequest.getNumber()).append(" ").append(merger != null ? merger.getLogin() + " " : "");
        }
        builder.append(context.getString(R.string.merged).toLowerCase()).append(" ");
        if (pullRequest.getHead() != null) {
            builder.bold(pullRequest.getHead().getRef()).append(" ").append(context.getString(R.string.to)).append(" ").bold(pullRequest.getBase().getRef()).append(" ");
        }
        builder.append(ParseDateFormat.getTimeAgo(pullRequest.getMergedAt()));
        return builder;
    } else {
        User user = pullRequest.getUser();
        String status = context.getString(pullRequest.getState().getStatus());
        SpannableBuilder builder = SpannableBuilder.builder();
        if (showRepoName) {
            PullsIssuesParser parser = PullsIssuesParser.getForPullRequest(pullRequest.getHtmlUrl());
            if (parser != null) {
                builder.bold(parser.getLogin()).append("/").bold(parser.getRepoId()).append(" ").bold("#").bold(String.valueOf(pullRequest.getNumber())).append(" ");
            }
        } else {
            builder.bold("#" + pullRequest.getNumber()).append(" ").append(user.getLogin()).append(" ");
        }
        if (pullRequest.getState() == IssueState.open && pullRequest.getHead() != null && pullRequest.getBase() != null) {
            return builder.append(context.getString(R.string.want_to_merge)).append(" ").bold(pullRequest.getHead().getRef()).append(" ").append(context.getString(R.string.to)).append(" ").bold(pullRequest.getBase().getRef()).append(" ").append(ParseDateFormat.getTimeAgo(pullRequest.getState() == IssueState.closed ? pullRequest.getClosedAt() : pullRequest.getCreatedAt()));
        } else {
            return builder.bold(status.toLowerCase()).append(" ").bold(pullRequest.getHead() != null ? pullRequest.getHead().getRef() : "").append(" ").append(ParseDateFormat.getTimeAgo(pullRequest.getState() == IssueState.closed ? pullRequest.getClosedAt() : pullRequest.getCreatedAt()));
        }
    }
}
Also used : SpannableBuilder(com.fastaccess.ui.widgets.SpannableBuilder) PullsIssuesParser(com.fastaccess.data.dao.PullsIssuesParser) NonNull(android.support.annotation.NonNull)

Example 4 with PullsIssuesParser

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

the class IssuePopupFragment method showPopup.

public static void showPopup(@NonNull FragmentManager manager, @NonNull PullRequest pullRequest) {
    IssuePopupFragment fragment = new IssuePopupFragment();
    PullsIssuesParser parser = PullsIssuesParser.getForPullRequest(pullRequest.getHtmlUrl());
    if (parser == null)
        return;
    fragment.setArguments(getBundle(parser.getLogin(), parser.getRepoId(), pullRequest.getNumber(), pullRequest.getTitle(), pullRequest.getBody(), pullRequest.getUser(), pullRequest.getAssignee(), pullRequest.getLabels(), pullRequest.getMilestone(), !pullRequest.isLocked()));
    fragment.show(manager, "");
}
Also used : PullsIssuesParser(com.fastaccess.data.dao.PullsIssuesParser)

Example 5 with PullsIssuesParser

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

Aggregations

PullsIssuesParser (com.fastaccess.data.dao.PullsIssuesParser)6 Login (com.fastaccess.data.dao.model.Login)2 User (com.fastaccess.data.dao.model.User)2 SpannableBuilder (com.fastaccess.ui.widgets.SpannableBuilder)2 NonNull (android.support.annotation.NonNull)1