use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class NewsEventTextTest method testIssueComment.
/**
* Verify text of issue comment event
*/
@UiThreadTest
public void testIssueComment() {
Issue issue = Issue.builder().number(5).build();
IssueCommentPayload payload = IssueCommentPayload.builder().issue(issue).build();
GitHubEvent event = createEvent(GitHubEventType.IssueCommentEvent, payload);
updateView(event);
verify("user commented on issue 5 on user/repo");
}
use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class NewsEventTextTest method testIssue.
/**
* Verify text of issue event
*/
@UiThreadTest
public void testIssue() {
Issue issue = Issue.builder().number(8).build();
IssuesPayload payload = IssuesPayload.builder().action("closed").issue(issue).build();
GitHubEvent event = createEvent(GitHubEventType.IssuesEvent, payload);
updateView(event);
verify("user closed issue 8 on user/repo");
}
use of com.meisolsson.githubsdk.model.Issue 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.Issue in project PocketHub by pockethub.
the class NewsFragment method onListItemClick.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
GitHubEvent event = (GitHubEvent) l.getItemAtPosition(position);
if (DownloadEvent.equals(event.type())) {
openDownload(event);
return;
}
if (PushEvent.equals(event.type())) {
openPush(event);
return;
}
if (CommitCommentEvent.equals(event.type())) {
openCommitComment(event);
return;
}
Issue issue = issueMatcher.getIssue(event);
if (issue != null) {
Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
viewIssue(issue, repo);
return;
}
Gist gist = gistMatcher.getGist(event);
if (gist != null) {
startActivity(GistsViewActivity.createIntent(gist));
return;
}
Repository repo = repoMatcher.getRepository(event);
if (repo != null) {
viewRepository(repo);
}
UserPair users = userMatcher.getUsers(event);
if (users != null) {
viewUser(users);
}
}
use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.
the class IssueStore method changeState.
public Issue changeState(Repository repository, int issueNumber, IssueState state) throws IOException {
IssueRequest editIssue = IssueRequest.builder().state(state).build();
Issue issue = service.editIssue(repository.owner().login(), repository.name(), issueNumber, editIssue).blockingGet();
return addIssue(repository, issue);
}
Aggregations