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());
}
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));
}
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);
}
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);
}
}
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++;
}
}
Aggregations