use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.
the class CommitCompareListFragment method updateList.
private void updateList(CommitCompare compare) {
if (!isUsable()) {
return;
}
this.compare = compare;
ViewUtils.setGone(progress, true);
ViewUtils.setGone(list, false);
LayoutInflater inflater = getActivity().getLayoutInflater();
adapter.clearHeaders();
adapter.getWrappedAdapter().clear();
List<Commit> commits = compare.commits();
if (!commits.isEmpty()) {
View commitHeader = inflater.inflate(R.layout.commit_details_header, null);
((TextView) commitHeader.findViewById(R.id.tv_commit_summary)).setText(MessageFormat.format(getString(R.string.comparing_commits), commits.size()));
adapter.addHeader(commitHeader);
adapter.addHeader(inflater.inflate(R.layout.list_divider, null));
CommitListAdapter commitAdapter = new CommitListAdapter(R.layout.commit_item, inflater, commits, avatars);
for (int i = 0; i < commits.size(); i++) {
Commit commit = commits.get(i);
View view = commitAdapter.getView(i, null, null);
adapter.addHeader(view, commit, true);
adapter.addHeader(inflater.inflate(R.layout.list_divider, null));
}
}
CommitFileListAdapter rootAdapter = adapter.getWrappedAdapter();
rootAdapter.clear();
List<GitHubFile> files = compare.files();
if (files != null && !files.isEmpty()) {
addFileStatHeader(files, inflater);
for (GitHubFile file : files) {
rootAdapter.addItem(file);
}
}
}
use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.
the class CommitCompareListFragment method openCommit.
private void openCommit(final Commit commit) {
if (compare != null) {
int commitPosition = 0;
Collection<Commit> commits = compare.commits();
for (Commit candidate : commits) {
if (commit == candidate) {
break;
} else {
commitPosition++;
}
}
if (commitPosition < commits.size()) {
startActivity(CommitViewActivity.createIntent(repository, commitPosition, commits));
}
} else {
startActivity(CommitViewActivity.createIntent(repository, commit.sha()));
}
}
use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.
the class CommitDiffListFragment method addCommitParents.
private void addCommitParents(Commit commit, LayoutInflater inflater) {
List<Commit> parents = commit.parents();
if (parents == null || parents.isEmpty()) {
return;
}
for (Commit parent : parents) {
View parentView = inflater.inflate(R.layout.commit_parent_item, null);
TextView parentIdText = (TextView) parentView.findViewById(R.id.tv_commit_id);
parentIdText.setPaintFlags(parentIdText.getPaintFlags() | UNDERLINE_TEXT_FLAG);
StyledText parentText = new StyledText();
parentText.append(getString(R.string.parent_prefix));
parentText.monospace(CommitUtils.abbreviate(parent.sha()));
parentIdText.setText(parentText);
adapter.addHeader(parentView, parent, true);
}
}
use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.
the class CommitViewActivity method createIntent.
/**
* Create intent for this activity
*
* @param repository
* @param position
* @param commits
* @return intent
*/
public static Intent createIntent(final Repository repository, final int position, final Collection<Commit> commits) {
String[] ids = new String[commits.size()];
int index = 0;
for (Commit commit : commits) {
ids[index++] = commit.sha();
}
return createIntent(repository, position, ids);
}
use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.
the class RefreshCommitTask method subscribe.
@Override
public void subscribe(ObservableEmitter<FullCommit> emitter) throws Exception {
try {
Commit commit = store.refreshCommit(repository, id);
GitCommit rawCommit = commit.commit();
if (rawCommit != null && rawCommit.commentCount() > 0) {
List<GitComment> comments = ServiceGenerator.createService(context, RepositoryCommentService.class).getCommitComments(repository.owner().login(), repository.name(), commit.sha(), 1).blockingGet().items();
for (GitComment comment : comments) {
imageGetter.encode(comment, comment.bodyHtml());
}
emitter.onNext(new FullCommit(commit, comments));
} else {
emitter.onNext(new FullCommit(commit));
}
} catch (IOException e) {
emitter.onError(e);
}
}
Aggregations