Search in sources :

Example 11 with SpannableBuilder

use of com.fastaccess.ui.widgets.SpannableBuilder 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 12 with SpannableBuilder

use of com.fastaccess.ui.widgets.SpannableBuilder in project FastHub by k0shk0sh.

the class IssuesViewHolder method bind.

@Override
public void bind(@NonNull Issue issueModel) {
    title.setText(issueModel.getTitle());
    if (issueModel.getState() != null) {
        CharSequence data = ParseDateFormat.getTimeAgo(issueModel.getState() == IssueState.open ? issueModel.getCreatedAt() : issueModel.getClosedAt());
        SpannableBuilder builder = SpannableBuilder.builder();
        if (showRepoName) {
            PullsIssuesParser parser = PullsIssuesParser.getForIssue(issueModel.getHtmlUrl());
            if (parser != null)
                builder.bold(parser.getLogin()).append("/").bold(parser.getRepoId()).bold("#").bold(String.valueOf(issueModel.getNumber())).append(" ").append(" ");
        }
        if (!showRepoName) {
            if (issueModel.getState() == IssueState.closed) {
                if (issueModel.getClosedBy() == null) {
                    builder.bold("#").bold(String.valueOf(issueModel.getNumber())).append(" ").append(" ");
                } else {
                    builder.append("#").append(String.valueOf(issueModel.getNumber())).append(" ").append(issueModel.getClosedBy().getLogin()).append(" ");
                }
            } else {
                builder.bold("#").bold(String.valueOf(issueModel.getNumber())).append(" ").append(issueModel.getUser().getLogin()).append(" ");
            }
        }
        details.setText(builder.append(itemView.getResources().getString(issueModel.getState().getStatus()).toLowerCase()).append(" ").append(data));
        if (issueModel.getComments() > 0) {
            commentsNo.setText(String.valueOf(issueModel.getComments()));
            commentsNo.setVisibility(View.VISIBLE);
        } else {
            commentsNo.setVisibility(View.GONE);
        }
    }
    if (showState) {
        issueState.setVisibility(View.VISIBLE);
        issueState.setImageResource(issueModel.getState() == IssueState.open ? R.drawable.ic_issue_opened_small : R.drawable.ic_issue_closed_small);
    } else {
        issueState.setVisibility(View.GONE);
    }
    if (withAvatar && avatarLayout != null) {
        avatarLayout.setUrl(issueModel.getUser().getAvatarUrl(), issueModel.getUser().getLogin(), false, LinkParserHelper.isEnterprise(issueModel.getUser().getHtmlUrl()));
        avatarLayout.setVisibility(View.VISIBLE);
    }
}
Also used : SpannableBuilder(com.fastaccess.ui.widgets.SpannableBuilder) PullsIssuesParser(com.fastaccess.data.dao.PullsIssuesParser)

Aggregations

SpannableBuilder (com.fastaccess.ui.widgets.SpannableBuilder)12 NonNull (android.support.annotation.NonNull)4 LabelModel (com.fastaccess.data.dao.LabelModel)4 User (com.fastaccess.data.dao.model.User)3 LabelSpan (com.fastaccess.ui.widgets.LabelSpan)3 PullsIssuesParser (com.fastaccess.data.dao.PullsIssuesParser)2 Bundle (android.os.Bundle)1 ContextCompat (android.support.v4.content.ContextCompat)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 BackgroundColorSpan (android.text.style.BackgroundColorSpan)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 BindColor (butterknife.BindColor)1 BindView (butterknife.BindView)1 Stream (com.annimon.stream.Stream)1 R (com.fastaccess.R)1 FilesListModel (com.fastaccess.data.dao.FilesListModel)1 GitCommitModel (com.fastaccess.data.dao.GitCommitModel)1 MilestoneModel (com.fastaccess.data.dao.MilestoneModel)1 PullRequestStatusModel (com.fastaccess.data.dao.PullRequestStatusModel)1