Search in sources :

Example 21 with Issue

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

the class IssuesPagerAdapter method getItem.

@Override
public Fragment getItem(int position) {
    IssueFragment fragment = new IssueFragment();
    Bundle args = new Bundle();
    if (repo != null) {
        args.putString(EXTRA_REPOSITORY_NAME, repo.name());
        User owner = repo.owner();
        args.putString(EXTRA_REPOSITORY_OWNER, owner.login());
        args.putParcelable(EXTRA_USER, owner);
    } else {
        Repository repo = repos.get(position);
        args.putString(EXTRA_REPOSITORY_NAME, repo.name());
        args.putString(EXTRA_REPOSITORY_OWNER, repo.owner().login());
        Issue issue = store.getIssue(repo, issues[position]);
        if (issue != null && issue.user() != null) {
            Repository fullRepo = issue.repository();
            if (fullRepo != null && fullRepo.owner() != null) {
                args.putParcelable(EXTRA_USER, fullRepo.owner());
            }
        }
    }
    args.putInt(EXTRA_ISSUE_NUMBER, issues[position]);
    args.putBoolean(EXTRA_CAN_WRITE_REPO, canWrite);
    fragment.setArguments(args);
    return fragment;
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) User(com.meisolsson.githubsdk.model.User) Issue(com.meisolsson.githubsdk.model.Issue) Bundle(android.os.Bundle)

Example 22 with Issue

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

the class IssuesViewActivity method createIntent.

/**
     * Create an intent to show issues with an initial selected issue
     *
     * @param issues
     * @param position
     * @return intent
     */
public static Intent createIntent(Collection<? extends Issue> issues, int position) {
    final int count = issues.size();
    int[] numbers = new int[count];
    boolean[] pullRequests = new boolean[count];
    ArrayList<Repository> repos = new ArrayList<>(count);
    int index = 0;
    for (Issue issue : issues) {
        numbers[index] = issue.number();
        pullRequests[index] = IssueUtils.isPullRequest(issue);
        index++;
        Repository repoId = null;
        Repository issueRepo = issue.repository();
        if (issueRepo != null) {
            User owner = issueRepo.owner();
            if (owner != null) {
                repoId = InfoUtils.createRepoFromData(owner.login(), issueRepo.name());
            }
        }
        if (repoId == null) {
            repoId = InfoUtils.createRepoFromUrl(issue.htmlUrl());
        }
        repos.add(repoId);
    }
    Builder builder = new Builder("issues.VIEW");
    builder.add(EXTRA_ISSUE_NUMBERS, numbers);
    builder.add(EXTRA_REPOSITORIES, repos);
    builder.add(EXTRA_POSITION, position);
    builder.add(EXTRA_PULL_REQUESTS, pullRequests);
    return builder.toIntent();
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Issue(com.meisolsson.githubsdk.model.Issue) User(com.meisolsson.githubsdk.model.User) Builder(com.github.pockethub.android.Intents.Builder) ArrayList(java.util.ArrayList)

Example 23 with Issue

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

the class IssuesViewActivity method createIntent.

/**
     * Create an intent to show issues with an initial selected issue
     *
     * @param issues
     * @param repository
     * @param position
     * @return intent
     */
public static Intent createIntent(final Collection<? extends Issue> issues, final Repository repository, final int position) {
    int[] numbers = new int[issues.size()];
    boolean[] pullRequests = new boolean[issues.size()];
    int index = 0;
    for (Issue issue : issues) {
        numbers[index] = issue.number();
        pullRequests[index] = IssueUtils.isPullRequest(issue);
        index++;
    }
    return new Builder("issues.VIEW").add(EXTRA_ISSUE_NUMBERS, numbers).add(EXTRA_REPOSITORY, repository).add(EXTRA_POSITION, position).add(EXTRA_PULL_REQUESTS, pullRequests).toIntent();
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue) Builder(com.github.pockethub.android.Intents.Builder)

Example 24 with Issue

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

the class SearchIssueListFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    final Issue searchIssue = (Issue) l.getItemAtPosition(position);
    startActivity(IssuesViewActivity.createIntent(searchIssue, repository));
}
Also used : Issue(com.meisolsson.githubsdk.model.Issue)

Aggregations

Issue (com.meisolsson.githubsdk.model.Issue)24 Repository (com.meisolsson.githubsdk.model.Repository)6 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)3 ArrayList (java.util.ArrayList)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 UiThreadTest (android.test.UiThreadTest)2 Builder (com.github.pockethub.android.Intents.Builder)2 FullIssue (com.github.pockethub.android.core.issue.FullIssue)2 ProgressObserverAdapter (com.github.pockethub.android.rx.ProgressObserverAdapter)2 GitHubComment (com.meisolsson.githubsdk.model.GitHubComment)2 User (com.meisolsson.githubsdk.model.User)2 IssueCommentPayload (com.meisolsson.githubsdk.model.payload.IssueCommentPayload)2 IssuesPayload (com.meisolsson.githubsdk.model.payload.IssuesPayload)2 IssueRequest (com.meisolsson.githubsdk.model.request.issue.IssueRequest)2 ActionBar (android.support.v7.app.ActionBar)1 ThrowableLoader (com.github.pockethub.android.ThrowableLoader)1 IssueFilter (com.github.pockethub.android.core.issue.IssueFilter)1 IssueStore (com.github.pockethub.android.core.issue.IssueStore)1 UserPair (com.github.pockethub.android.core.user.UserEventMatcher.UserPair)1