use of com.meisolsson.githubsdk.model.Label in project PocketHub by pockethub.
the class IssueFragment method updateHeader.
private void updateHeader(final Issue issue) {
if (!isUsable()) {
return;
}
titleText.setText(issue.title());
String body = issue.bodyHtml();
if (!TextUtils.isEmpty(body)) {
bodyImageGetter.bind(bodyText, body, issue.id());
} else {
bodyText.setText(R.string.no_description_given);
}
authorText.setText(issue.user().login());
createdDateText.setText(new StyledText().append(getString(R.string.prefix_opened)).append(issue.createdAt()));
avatars.bind(creatorAvatar, issue.user());
if (IssueUtils.isPullRequest(issue) && issue.pullRequest().commits() != null && issue.pullRequest().commits() > 0) {
ViewUtils.setGone(commitsView, false);
TextView icon = (TextView) headerView.findViewById(R.id.tv_commit_icon);
TypefaceUtils.setOcticons(icon);
icon.setText(ICON_COMMIT);
String commits = getString(R.string.pull_request_commits, issue.pullRequest().commits());
((TextView) headerView.findViewById(R.id.tv_pull_request_commits)).setText(commits);
} else {
ViewUtils.setGone(commitsView, true);
}
boolean open = IssueState.open.equals(issue.state());
if (!open) {
StyledText text = new StyledText();
text.bold(getString(R.string.closed));
Date closedAt = issue.closedAt();
if (closedAt != null) {
text.append(' ').append(closedAt);
}
stateText.setText(text);
}
ViewUtils.setGone(stateText, open);
User assignee = issue.assignee();
if (assignee != null) {
StyledText name = new StyledText();
name.bold(assignee.login());
name.append(' ').append(getString(R.string.assigned));
assigneeText.setText(name);
assigneeAvatar.setVisibility(VISIBLE);
avatars.bind(assigneeAvatar, assignee);
} else {
assigneeAvatar.setVisibility(GONE);
assigneeText.setText(R.string.unassigned);
}
List<Label> labels = issue.labels();
if (labels != null && !labels.isEmpty()) {
LabelDrawableSpan.setText(labelsArea, labels);
labelsArea.setVisibility(VISIBLE);
} else {
labelsArea.setVisibility(GONE);
}
if (issue.milestone() != null) {
Milestone milestone = issue.milestone();
StyledText milestoneLabel = new StyledText();
milestoneLabel.append(getString(R.string.milestone_prefix));
milestoneLabel.append(' ');
milestoneLabel.bold(milestone.title());
milestoneText.setText(milestoneLabel);
float closed = milestone.closedIssues();
float total = closed + milestone.openIssues();
if (total > 0) {
((LayoutParams) milestoneProgressArea.getLayoutParams()).weight = closed / total;
milestoneProgressArea.setVisibility(VISIBLE);
} else {
milestoneProgressArea.setVisibility(GONE);
}
milestoneArea.setVisibility(VISIBLE);
} else {
milestoneArea.setVisibility(GONE);
}
ViewUtils.setGone(progress, true);
ViewUtils.setGone(list, false);
updateStateItem(issue);
}
use of com.meisolsson.githubsdk.model.Label in project PocketHub by pockethub.
the class LabelsDialog method load.
private void load(final Collection<Label> selectedLabels) {
getPageAndNext(1).subscribe(new ProgressObserverAdapter<Page<Label>>(activity, R.string.loading_labels) {
List<Label> repositoryLabels = new ArrayList<>();
@Override
public void onNext(Page<Label> page) {
repositoryLabels.addAll(page.items());
}
@Override
public void onComplete() {
super.onComplete();
Map<String, Label> loadedLabels = new TreeMap<>(CASE_INSENSITIVE_ORDER);
for (Label label : repositoryLabels) {
loadedLabels.put(label.name(), label);
}
labels = loadedLabels;
dismissProgress();
show(selectedLabels);
}
@Override
public void onError(Throwable error) {
dismissProgress();
Log.e(TAG, "Exception loading labels", error);
ToastUtils.show(activity, error, R.string.error_labels_load);
}
}.start());
}
Aggregations