Search in sources :

Example 1 with GitComment

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

the class FullCommitTest method testSingleCommentNoFiles.

/**
     * Test commit with no files and one commit comment
     */
public void testSingleCommentNoFiles() {
    GitComment comment = GitComment.builder().build();
    Commit commit = Commit.builder().build();
    FullCommit full = new FullCommit(commit, Collections.singletonList(comment));
    assertFalse(full.isEmpty());
    assertEquals(comment, full.get(0));
    assertTrue(full.getFiles().isEmpty());
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Example 2 with GitComment

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

the class FullCommitTest method testBothTypesOfComments.

/**
     * Test commit with line and global comments
     */
public void testBothTypesOfComments() {
    GitHubFile file = GitHubFile.builder().filename("a.txt").build();
    GitComment comment1 = GitComment.builder().path(file.filename()).position(10).build();
    GitComment comment2 = GitComment.builder().build();
    Commit commit = Commit.builder().files(Collections.singletonList(file)).build();
    FullCommit full = new FullCommit(commit, new ArrayList<>(Arrays.asList(comment1, comment2)));
    assertEquals(1, full.size());
    assertEquals(comment2, full.get(0));
    assertEquals(1, full.getFiles().size());
    assertEquals(comment1, full.getFiles().get(0).get(10).get(0));
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Example 3 with GitComment

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

the class CommitDiffListFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (RESULT_OK == resultCode && COMMENT_CREATE == requestCode && data != null) {
        GitComment comment = data.getParcelableExtra(EXTRA_COMMENT);
        addComment(comment);
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
Also used : GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Example 4 with GitComment

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

the class CommitDiffListFragment method updateItems.

private void updateItems(List<GitComment> comments, List<FullCommitFile> files) {
    CommitFileListAdapter rootAdapter = adapter.getWrappedAdapter();
    rootAdapter.clear();
    for (FullCommitFile file : files) {
        rootAdapter.addItem(file);
    }
    for (GitComment comment : comments) {
        rootAdapter.addComment(comment);
    }
}
Also used : FullCommitFile(com.github.pockethub.android.core.commit.FullCommitFile) GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Example 5 with GitComment

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

the class CommitFileListAdapter method addItem.

/**
     * Add file to adapter
     *
     * @param file
     */
public void addItem(final FullCommitFile file) {
    addItem(TYPE_FILE_HEADER, file.getFile());
    List<CharSequence> lines = diffStyler.get(file.getFile().filename());
    int number = 0;
    for (CharSequence line : lines) {
        addItem(TYPE_FILE_LINE, line);
        for (GitComment comment : file.get(number)) {
            addItem(TYPE_LINE_COMMENT, comment);
        }
        number++;
    }
}
Also used : GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Aggregations

GitComment (com.meisolsson.githubsdk.model.git.GitComment)10 Commit (com.meisolsson.githubsdk.model.Commit)5 FullCommit (com.github.pockethub.android.core.commit.FullCommit)4 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)4 FullCommitFile (com.github.pockethub.android.core.commit.FullCommitFile)1 StyledText (com.github.pockethub.android.ui.StyledText)1 Repository (com.meisolsson.githubsdk.model.Repository)1 GitCommit (com.meisolsson.githubsdk.model.git.GitCommit)1 CommitCommentPayload (com.meisolsson.githubsdk.model.payload.CommitCommentPayload)1 RepositoryCommentService (com.meisolsson.githubsdk.service.repositories.RepositoryCommentService)1 IOException (java.io.IOException)1