use of com.meisolsson.githubsdk.model.Milestone in project PocketHub by pockethub.
the class IssueFilterTest method testEqualFilter.
/**
* Verify {@link IssueFilter#equals(Object)}
*/
@Test
public void testEqualFilter() {
Repository repo = Repository.builder().id(1L).build();
IssueFilter filter1 = new IssueFilter(repo, UUID.randomUUID().toString());
assertFalse(filter1.equals(null));
assertFalse(filter1.equals(""));
assertTrue(filter1.equals(filter1));
IssueFilter filter2 = new IssueFilter(repo, UUID.randomUUID().toString());
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
User user = User.builder().id(2L).build();
filter1.setAssignee(user);
assertFalse(filter1.equals(filter2));
filter2.setAssignee(user);
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
filter1.setOpen(false);
assertFalse(filter1.equals(filter2));
filter2.setOpen(false);
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
Milestone milestone = Milestone.builder().number(3).build();
filter1.setMilestone(milestone);
assertFalse(filter1.equals(filter2));
filter2.setMilestone(milestone);
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
}
use of com.meisolsson.githubsdk.model.Milestone 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.Milestone in project gh4a by slapperwan.
the class IssueEditActivity method saveIssue.
private void saveIssue() {
Milestone milestone = mEditIssue.milestone();
IssueRequest.Builder builder = IssueRequest.builder();
if (!ObjectsCompat.equals(mEditIssue.title(), mOriginalIssue.title())) {
builder.title(mEditIssue.title());
}
if (!ObjectsCompat.equals(mEditIssue.body(), mOriginalIssue.body())) {
builder.body(mEditIssue.body());
}
if (!ObjectsCompat.equals(mEditIssue.milestone(), mOriginalIssue.milestone())) {
builder.milestone(milestone != null ? milestone.number() : null);
}
if (!ObjectsCompat.equals(mEditIssue.assignees(), mOriginalIssue.assignees())) {
List<String> assignees = new ArrayList<>();
for (User assignee : mEditIssue.assignees()) {
assignees.add(assignee.login());
}
builder.assignees(assignees);
}
if (!ObjectsCompat.equals(mEditIssue.labels(), mOriginalIssue.labels())) {
List<String> labels = new ArrayList<>();
for (Label label : mEditIssue.labels()) {
labels.add(label.name());
}
builder.labels(labels);
}
Integer issueNumber = mEditIssue.number();
String errorMessage = issueNumber != null ? getString(R.string.issue_error_edit, issueNumber) : getString(R.string.issue_error_create);
IssueService service = ServiceFactory.get(IssueService.class, false);
Single<Response<Issue>> single = isInEditMode() ? service.editIssue(mRepoOwner, mRepoName, issueNumber, builder.build()) : service.createIssue(mRepoOwner, mRepoName, builder.build());
single.map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.saving_msg, errorMessage)).subscribe(result -> {
Intent data = new Intent();
Bundle extras = new Bundle();
extras.putParcelable("issue", result);
data.putExtras(extras);
setResult(RESULT_OK, data);
finish();
}, error -> handleActionFailure("Saving issue failed", error));
}
Aggregations