Search in sources :

Example 6 with Repository

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

the class NewsFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    GitHubEvent event = (GitHubEvent) l.getItemAtPosition(position);
    if (DownloadEvent.equals(event.type())) {
        openDownload(event);
        return;
    }
    if (PushEvent.equals(event.type())) {
        openPush(event);
        return;
    }
    if (CommitCommentEvent.equals(event.type())) {
        openCommitComment(event);
        return;
    }
    Issue issue = issueMatcher.getIssue(event);
    if (issue != null) {
        Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
        viewIssue(issue, repo);
        return;
    }
    Gist gist = gistMatcher.getGist(event);
    if (gist != null) {
        startActivity(GistsViewActivity.createIntent(gist));
        return;
    }
    Repository repo = repoMatcher.getRepository(event);
    if (repo != null) {
        viewRepository(repo);
    }
    UserPair users = userMatcher.getUsers(event);
    if (users != null) {
        viewUser(users);
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Gist(com.meisolsson.githubsdk.model.Gist) Issue(com.meisolsson.githubsdk.model.Issue) UserPair(com.github.pockethub.android.core.user.UserEventMatcher.UserPair) GitHubEvent(com.meisolsson.githubsdk.model.GitHubEvent)

Example 7 with Repository

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

the class EditIssuesFilterActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_issues_filter_edit);
    if (savedInstanceState != null) {
        filter = savedInstanceState.getParcelable(EXTRA_ISSUE_FILTER);
    }
    if (filter == null) {
        filter = getIntent().getParcelableExtra(EXTRA_ISSUE_FILTER);
    }
    Repository repository = filter.getRepository();
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(R.string.filter_issues_title);
    actionBar.setSubtitle(InfoUtils.createRepoId(repository));
    avatars.bind(actionBar, repository.owner());
    updateAssignee();
    updateMilestone();
    updateLabels();
    RadioGroup status = findViewById(R.id.issue_filter_status);
    RadioGroup sortOrder = findViewById(R.id.issue_sort_order);
    RadioGroup sortType = findViewById(R.id.issue_sort_type);
    status.setOnCheckedChangeListener(this::onStatusChanged);
    sortOrder.setOnCheckedChangeListener(this::onSortOrderChanged);
    sortType.setOnCheckedChangeListener(this::onSortTypeChanged);
    if (filter.isOpen()) {
        status.check(R.id.rb_open);
    } else {
        status.check(R.id.rb_closed);
    }
    if (filter.getDirection().equals(IssueFilter.DIRECTION_ASCENDING)) {
        sortOrder.check(R.id.rb_asc);
    } else {
        sortOrder.check(R.id.rb_desc);
    }
    switch(filter.getSortType()) {
        case IssueFilter.SORT_CREATED:
            sortType.check(R.id.rb_created);
            break;
        case IssueFilter.SORT_UPDATED:
            sortType.check(R.id.rb_updated);
            break;
        case IssueFilter.SORT_COMMENTS:
            sortType.check(R.id.rb_comments);
            break;
        default:
            break;
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) RadioGroup(android.widget.RadioGroup) ActionBar(android.support.v7.app.ActionBar)

Example 8 with Repository

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

the class IssuesViewActivity method onPageSelected.

@Override
public void onPageSelected(final int position) {
    super.onPageSelected(position);
    if (repo != null) {
        updateTitle(position);
        return;
    }
    if (repoIds == null) {
        return;
    }
    ActionBar actionBar = getSupportActionBar();
    repo = repoIds.get(position);
    if (repo != null) {
        updateTitle(position);
        actionBar.setSubtitle(InfoUtils.createRepoId(repo));
        Issue issue = store.getIssue(repo, issueNumbers[position]);
        if (issue != null) {
            Repository fullRepo = issue.repository();
            if (fullRepo != null && fullRepo.owner() != null) {
                user = fullRepo.owner();
                avatars.bind(actionBar, user);
            } else {
                actionBar.setLogo(null);
            }
        } else {
            actionBar.setLogo(null);
        }
    } else {
        actionBar.setSubtitle(null);
        actionBar.setLogo(null);
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Issue(com.meisolsson.githubsdk.model.Issue) ActionBar(android.support.v7.app.ActionBar)

Example 9 with Repository

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

the class NotificationListFragment method updateHeaders.

private void updateHeaders(final List<Item> notifications) {
    if (notifications.isEmpty()) {
        return;
    }
    Collections.sort(notifications, (i1, i2) -> {
        Repository r1 = ((NotificationItem) i1).getNotificationThread().repository();
        Repository r2 = ((NotificationItem) i2).getNotificationThread().repository();
        return r1.fullName().compareToIgnoreCase(r2.fullName());
    });
    Repository repoFound = null;
    for (int i = 0; i < notifications.size(); i++) {
        NotificationItem item = (NotificationItem) notifications.get(i);
        NotificationThread thread = item.getNotificationThread();
        String fullName = thread.repository().fullName();
        if (repoFound == null || !fullName.equals(repoFound.fullName())) {
            notifications.add(i, new NotificationHeaderItem(thread.repository(), this));
        }
        repoFound = thread.repository();
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) NotificationItem(com.github.pockethub.android.ui.item.notification.NotificationItem) NotificationThread(com.meisolsson.githubsdk.model.NotificationThread) NotificationHeaderItem(com.github.pockethub.android.ui.item.notification.NotificationHeaderItem)

Example 10 with Repository

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

the class RepositoryListFragment method updateHeaders.

private void updateHeaders(final List<Item> repos) {
    if (repos.isEmpty()) {
        return;
    }
    // Add recent header if at least one recent repository
    Repository first = ((RepositoryItem) repos.get(0)).getRepo();
    if (recentRepos.contains(first)) {
        repos.add(0, new RepositoryHeaderItem(getString(R.string.recently_viewed)));
    }
    // Advance past all recent repositories
    int index;
    for (index = 0; index < repos.size(); index++) {
        Item item = repos.get(index);
        if (item instanceof RepositoryItem) {
            Repository repository = ((RepositoryItem) item).getRepo();
            if (!recentRepos.contains(repository.id())) {
                break;
            }
        }
    }
    if (index >= repos.size()) {
        return;
    }
    // Register header for first character
    Repository current = ((RepositoryItem) repos.get(index)).getRepo();
    char start = Character.toLowerCase(current.name().charAt(0));
    repos.add(index, new RepositoryHeaderItem(Character.toString(start).toUpperCase(US)));
    for (index = index + 1; index < repos.size(); index++) {
        current = ((RepositoryItem) repos.get(index)).getRepo();
        char repoStart = Character.toLowerCase(current.name().charAt(0));
        if (repoStart <= start) {
            continue;
        }
        repos.add(index, new RepositoryHeaderItem(Character.toString(repoStart).toUpperCase(US)));
        start = repoStart;
    }
}
Also used : RepositoryItem(com.github.pockethub.android.ui.item.repository.RepositoryItem) RepositoryItem(com.github.pockethub.android.ui.item.repository.RepositoryItem) Item(com.xwray.groupie.Item) RepositoryHeaderItem(com.github.pockethub.android.ui.item.repository.RepositoryHeaderItem) Repository(com.meisolsson.githubsdk.model.Repository) RepositoryHeaderItem(com.github.pockethub.android.ui.item.repository.RepositoryHeaderItem)

Aggregations

Repository (com.meisolsson.githubsdk.model.Repository)68 User (com.meisolsson.githubsdk.model.User)18 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)9 Issue (com.meisolsson.githubsdk.model.Issue)9 Intent (android.content.Intent)8 View (android.view.View)8 TextView (android.widget.TextView)6 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 LayoutInflater (android.view.LayoutInflater)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 Test (org.junit.Test)4 Uri (android.net.Uri)3 Menu (android.view.Menu)3 ViewGroup (android.view.ViewGroup)3 LinearLayout (android.widget.LinearLayout)3 R (com.gh4a.R)3 RepositoryActivity (com.gh4a.activities.RepositoryActivity)3 UserActivity (com.gh4a.activities.UserActivity)3 ApiHelpers (com.gh4a.utils.ApiHelpers)3