use of com.meisolsson.githubsdk.model.Label in project PocketHub by pockethub.
the class EditIssueActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.m_apply:
IssueRequest.Builder request = IssueRequest.builder().body(bodyText.getText().toString()).title(titleText.getText().toString()).state(issue.state());
if (issue.assignee() != null) {
request.assignees(Collections.singletonList(issue.assignee().login()));
}
if (issue.milestone() != null) {
request.milestone(issue.milestone().number());
}
if (issue.labels() != null) {
List<String> labels = new ArrayList<>();
for (Label label : issue.labels()) {
labels.add(label.name());
}
request.labels(labels);
}
IssueService service = ServiceGenerator.createService(this, IssueService.class);
Single<Issue> single;
int message;
if (issue.number() != null && issue.number() > 0) {
single = service.editIssue(repository.owner().login(), repository.name(), issue.number(), request.build());
message = R.string.updating_issue;
} else {
single = service.createIssue(repository.owner().login(), repository.name(), request.build());
message = R.string.creating_issue;
}
single.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(this.<Issue>bindToLifecycle()).subscribe(new ProgressObserverAdapter<Issue>(this, message) {
@Override
public void onSuccess(Issue issue) {
super.onSuccess(issue);
Intent intent = new Intent();
intent.putExtra(EXTRA_ISSUE, issue);
setResult(RESULT_OK, intent);
finish();
}
@Override
public void onError(Throwable e) {
super.onError(e);
Log.e(TAG, "Exception creating issue", e);
ToastUtils.show(EditIssueActivity.this, e.getMessage());
}
}.start());
return true;
default:
return super.onOptionsItemSelected(item);
}
}
use of com.meisolsson.githubsdk.model.Label in project PocketHub by pockethub.
the class EditLabelsTask method subscribe.
@Override
public void subscribe(ObservableEmitter<Issue> emitter) throws Exception {
try {
List<String> labelNames = new ArrayList<>(labels.length);
for (Label label : labels) {
labelNames.add(label.name());
}
IssueRequest editIssue = IssueRequest.builder().labels(labelNames).build();
emitter.onNext(store.editIssue(repositoryId, issueNumber, editIssue));
} catch (IOException e) {
emitter.onError(e);
}
}
use of com.meisolsson.githubsdk.model.Label in project PocketHub by pockethub.
the class FilterListAdapter method update.
@Override
protected void update(int position, IssueFilter filter) {
avatars.bind(imageView(0), filter.getRepository().owner());
setText(1, InfoUtils.createRepoId(filter.getRepository()));
if (filter.isOpen()) {
setText(2, R.string.open_issues);
} else {
setText(2, R.string.closed_issues);
}
Collection<Label> labels = filter.getLabels();
if (labels != null && !labels.isEmpty()) {
TextView labelsText = textView(3);
LabelDrawableSpan.setText(labelsText, labels);
ViewUtils.setGone(labelsText, false);
} else {
setGone(3, true);
}
Milestone milestone = filter.getMilestone();
if (milestone != null) {
ViewUtils.setGone(setText(4, milestone.title()), false);
} else {
setGone(4, true);
}
User assignee = filter.getAssignee();
if (assignee != null) {
avatars.bind(imageView(7), assignee);
ViewUtils.setGone(setText(6, assignee.login()), false);
} else {
setGone(5, true);
}
}
use of com.meisolsson.githubsdk.model.Label in project PocketHub by pockethub.
the class IssueFilter method toDisplay.
/**
* Get display {@link CharSequence} representing this filter
*
* @return display
*/
public CharSequence toDisplay() {
List<String> segments = new ArrayList<>();
if (open) {
segments.add("Open issues");
} else {
segments.add("Closed issues");
}
if (assignee != null) {
segments.add("Assignee: " + assignee.login());
}
if (milestone != null) {
segments.add("Milestone: " + milestone.title());
}
if (labels != null && !labels.isEmpty()) {
StringBuilder builder = new StringBuilder("Labels: ");
for (Label label : labels) {
builder.append(label.name()).append(',').append(' ');
}
builder.deleteCharAt(builder.length() - 1);
builder.deleteCharAt(builder.length() - 1);
segments.add(builder.toString());
}
if (segments.isEmpty()) {
return "";
}
StringBuilder all = new StringBuilder();
for (String segment : segments) {
all.append(segment).append(',').append(' ');
}
all.deleteCharAt(all.length() - 1);
all.deleteCharAt(all.length() - 1);
return all;
}
use of com.meisolsson.githubsdk.model.Label in project PocketHub by pockethub.
the class IssuesFragment method updateFilterSummary.
private void updateFilterSummary() {
if (filter.isOpen()) {
state.setText(R.string.open_issues);
} else {
state.setText(R.string.closed_issues);
}
Collection<Label> filterLabels = filter.getLabels();
if (filterLabels != null && !filterLabels.isEmpty()) {
LabelDrawableSpan.setText(labels, filterLabels);
labels.setVisibility(VISIBLE);
} else {
labels.setVisibility(GONE);
}
Milestone filterMilestone = filter.getMilestone();
if (filterMilestone != null) {
milestone.setText(filterMilestone.title());
milestone.setVisibility(VISIBLE);
} else {
milestone.setVisibility(GONE);
}
User user = filter.getAssignee();
if (user != null) {
avatars.bind(assigneeAvatar, user);
assignee.setText(user.login());
assigneeArea.setVisibility(VISIBLE);
} else {
assigneeArea.setVisibility(GONE);
}
}
Aggregations