Search in sources :

Example 1 with Issue

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");
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent) IssueCommentPayload(com.meisolsson.githubsdk.model.payload.IssueCommentPayload) UiThreadTest(android.test.UiThreadTest)

Example 2 with Issue

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");
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue) IssuesPayload(com.meisolsson.githubsdk.model.payload.IssuesPayload) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent) UiThreadTest(android.test.UiThreadTest)

Example 3 with Issue

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);
    }
}
Also used : IssueService(com.meisolsson.githubsdk.service.issues.IssueService) Issue(com.meisolsson.githubsdk.model.Issue) ProgressObserverAdapter(com.github.pockethub.android.rx.ProgressObserverAdapter) ArrayList(java.util.ArrayList) Label(com.meisolsson.githubsdk.model.Label) Intent(android.content.Intent) IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest)

Example 4 with Issue

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);
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Gist(com.meisolsson.githubsdk.model.Gist) Issue(com.meisolsson.githubsdk.model.Issue) UserPair(com.github.pockethub.android.core.user.UserEventMatcher.UserPair) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent)

Example 5 with Issue

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);
}
Also used : IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest) Issue(com.meisolsson.githubsdk.model.Issue)

Aggregations

Issue (com.meisolsson.githubsdk.model.Issue)24 Repository (com.meisolsson.githubsdk.model.Repository)6 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)3 ArrayList (java.util.ArrayList)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 UiThreadTest (android.test.UiThreadTest)2 Builder (com.github.pockethub.android.Intents.Builder)2 FullIssue (com.github.pockethub.android.core.issue.FullIssue)2 ProgressObserverAdapter (com.github.pockethub.android.rx.ProgressObserverAdapter)2 GitHubComment (com.meisolsson.githubsdk.model.GitHubComment)2 User (com.meisolsson.githubsdk.model.User)2 IssueCommentPayload (com.meisolsson.githubsdk.model.payload.IssueCommentPayload)2 IssuesPayload (com.meisolsson.githubsdk.model.payload.IssuesPayload)2 IssueRequest (com.meisolsson.githubsdk.model.request.issue.IssueRequest)2 ActionBar (android.support.v7.app.ActionBar)1 ThrowableLoader (com.github.pockethub.android.ThrowableLoader)1 IssueFilter (com.github.pockethub.android.core.issue.IssueFilter)1 IssueStore (com.github.pockethub.android.core.issue.IssueStore)1 UserPair (com.github.pockethub.android.core.user.UserEventMatcher.UserPair)1