Search in sources :

Example 1 with CommitItem

use of com.github.pockethub.android.ui.item.commit.CommitItem in project PocketHub by pockethub.

the class CommitCompareListFragment method updateList.

private void updateList(CommitCompare compare) {
    if (!isAdded()) {
        return;
    }
    this.compare = compare;
    progress.setVisibility(View.GONE);
    list.setVisibility(View.VISIBLE);
    List<Commit> commits = compare.commits();
    if (!commits.isEmpty()) {
        String comparingCommits = getString(R.string.comparing_commits);
        String text = MessageFormat.format(comparingCommits, commits.size());
        commitsSection.setHeader(new TextItem(R.layout.commit_details_header, R.id.tv_commit_summary, text));
        List<CommitItem> items = new ArrayList<>();
        for (Commit commit : commits) {
            items.add(new CommitItem(avatars, commit));
        }
        commitsSection.update(items);
    }
    List<GitHubFile> files = compare.files();
    if (!files.isEmpty()) {
        filesSection.setHeader(new TextItem(R.layout.commit_compare_file_details_header, R.id.tv_commit_file_summary, CommitUtils.formatStats(files)));
        filesSection.update(createFileSections(files));
    }
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) TextItem(com.github.pockethub.android.ui.item.TextItem) CommitItem(com.github.pockethub.android.ui.item.commit.CommitItem) ArrayList(java.util.ArrayList) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile)

Example 2 with CommitItem

use of com.github.pockethub.android.ui.item.commit.CommitItem 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<Item> commits) {
    String[] ids = new String[commits.size()];
    int index = 0;
    for (Item item : commits) {
        Commit commit = ((CommitItem) item).getCommit();
        ids[index++] = commit.sha();
    }
    return createIntent(repository, position, ids);
}
Also used : MenuItem(android.view.MenuItem) CommitItem(com.github.pockethub.android.ui.item.commit.CommitItem) Item(com.xwray.groupie.Item) Commit(com.meisolsson.githubsdk.model.Commit) CommitItem(com.github.pockethub.android.ui.item.commit.CommitItem)

Aggregations

CommitItem (com.github.pockethub.android.ui.item.commit.CommitItem)2 Commit (com.meisolsson.githubsdk.model.Commit)2 MenuItem (android.view.MenuItem)1 TextItem (com.github.pockethub.android.ui.item.TextItem)1 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)1 Item (com.xwray.groupie.Item)1 ArrayList (java.util.ArrayList)1