Search in sources :

Example 16 with Issue

use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.

the class IssueUriMatcherTest method testHttpsUri.

/**
     * Verify https uri
     */
public void testHttpsUri() {
    Issue issue = IssueUriMatcher.getIssue(Uri.parse("http://github.com/defunkt/resque/issues/15"));
    assertNotNull(issue);
    assertEquals(15, issue.number().intValue());
    assertNotNull(issue.repository());
    assertEquals("resque", issue.repository().name());
    assertNotNull(issue.repository().owner());
    assertEquals("defunkt", issue.repository().owner().login());
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue)

Example 17 with Issue

use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.

the class IssueUriMatcherTest method testCommentUri.

/**
     * Verify uri with comment fragment
     */
public void testCommentUri() {
    Issue issue = IssueUriMatcher.getIssue(Uri.parse("https://github.com/defunkt/resque/issues/300#issuecomment-123456"));
    assertNotNull(issue);
    assertEquals(300, issue.number().intValue());
    assertNotNull(issue.repository());
    assertEquals("resque", issue.repository().name());
    assertNotNull(issue.repository().owner());
    assertEquals("defunkt", issue.repository().owner().login());
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue)

Example 18 with Issue

use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.

the class IssueFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (RESULT_OK != resultCode || data == null) {
        return;
    }
    switch(requestCode) {
        case ISSUE_EDIT:
            Issue editedIssue = data.getParcelableExtra(EXTRA_ISSUE);
            bodyImageGetter.encode(editedIssue.id(), editedIssue.bodyHtml());
            updateHeader(editedIssue);
            return;
        case COMMENT_CREATE:
            GitHubComment comment = data.getParcelableExtra(EXTRA_COMMENT);
            if (items != null) {
                items.add(comment);
                issue = issue.toBuilder().comments(issue.comments() + 1).build();
                updateList(issue, items);
            } else {
                refreshIssue();
            }
            return;
        case COMMENT_EDIT:
            comment = data.getParcelableExtra(EXTRA_COMMENT);
            if (items != null && comment != null) {
                int commentPosition = findCommentPositionInItems(comment);
                if (commentPosition >= 0) {
                    commentImageGetter.removeFromCache(comment.id());
                    replaceCommentInItems(commentPosition, comment);
                    updateList(issue, items);
                }
            } else {
                refreshIssue();
            }
    }
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue) FullIssue(com.github.pockethub.android.core.issue.FullIssue) GitHubComment(com.meisolsson.githubsdk.model.GitHubComment)

Example 19 with Issue

use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.

the class IssueFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    repositoryId = InfoUtils.createRepoFromData(args.getString(EXTRA_REPOSITORY_OWNER), args.getString(EXTRA_REPOSITORY_NAME));
    issueNumber = args.getInt(EXTRA_ISSUE_NUMBER);
    user = args.getParcelable(EXTRA_USER);
    canWrite = args.getBoolean(EXTRA_CAN_WRITE_REPO, false);
    BaseActivity dialogActivity = (BaseActivity) getActivity();
    ProgressObserverAdapter<Issue> observer = new ProgressObserverAdapter<Issue>(getActivity()) {

        @Override
        public void onNext(Issue issue) {
            super.onNext(issue);
            updateHeader(issue);
            refreshIssue();
        }
    };
    milestoneTask = new EditMilestoneTask(dialogActivity, repositoryId, issueNumber, observer);
    assigneeTask = new EditAssigneeTask(dialogActivity, repositoryId, issueNumber, observer);
    labelsTask = new EditLabelsTask(dialogActivity, repositoryId, issueNumber, observer);
    stateTask = new EditStateTask(dialogActivity, repositoryId, issueNumber, observer);
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue) FullIssue(com.github.pockethub.android.core.issue.FullIssue) Bundle(android.os.Bundle) ProgressObserverAdapter(com.github.pockethub.android.rx.ProgressObserverAdapter) BaseActivity(com.github.pockethub.android.ui.BaseActivity)

Example 20 with Issue

use of com.meisolsson.githubsdk.model.Issue in project PocketHub by pockethub.

the class IssuesFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == ISSUE_FILTER_EDIT && data != null) {
        IssueFilter newFilter = data.getParcelableExtra(EXTRA_ISSUE_FILTER);
        if (!filter.equals(newFilter)) {
            filter = newFilter;
            updateFilterSummary();
            pager.reset();
            refreshWithProgress();
            return;
        }
    }
    if (requestCode == ISSUE_VIEW) {
        notifyDataSetChanged();
        forceRefresh();
        return;
    }
    if (requestCode == ISSUE_CREATE && resultCode == RESULT_OK) {
        Issue created = data.getParcelableExtra(EXTRA_ISSUE);
        forceRefresh();
        startActivityForResult(IssuesViewActivity.createIntent(created, repository), ISSUE_VIEW);
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue) IssueFilter(com.github.pockethub.android.core.issue.IssueFilter)

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