Search in sources :

Example 6 with Commit

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);
        }
    }
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) LayoutInflater(android.view.LayoutInflater) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 7 with Commit

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()));
    }
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit)

Example 8 with Commit

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);
    }
}
Also used : GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) Commit(com.meisolsson.githubsdk.model.Commit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) StyledText(com.github.pockethub.android.ui.StyledText) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 9 with Commit

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);
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit)

Example 10 with Commit

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);
    }
}
Also used : GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) Commit(com.meisolsson.githubsdk.model.Commit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) RepositoryCommentService(com.meisolsson.githubsdk.service.repositories.RepositoryCommentService) GitComment(com.meisolsson.githubsdk.model.git.GitComment) IOException(java.io.IOException)

Aggregations

Commit (com.meisolsson.githubsdk.model.Commit)16 GitCommit (com.meisolsson.githubsdk.model.git.GitCommit)7 FullCommit (com.github.pockethub.android.core.commit.FullCommit)6 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)5 GitComment (com.meisolsson.githubsdk.model.git.GitComment)5 GitUser (com.meisolsson.githubsdk.model.git.GitUser)4 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 Date (java.util.Date)2 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 StyledText (com.github.pockethub.android.ui.StyledText)1 RepositoryCommentService (com.meisolsson.githubsdk.service.repositories.RepositoryCommentService)1 IOException (java.io.IOException)1