Search in sources :

Example 21 with User

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

the class RepositoryListFragment method onCreateLoader.

@Override
public Loader<List<Repository>> onCreateLoader(int id, final Bundle args) {
    return new ThrowableLoader<List<Repository>>(getActivity(), items) {

        @Override
        public List<Repository> loadData() throws Exception {
            User org = RepositoryListFragment.this.org.get();
            if (org == null) {
                return Collections.emptyList();
            }
            List<Repository> repos = cache.getRepos(org, isForceRefresh(args));
            Collections.sort(repos, recentRepos);
            updateHeaders(repos);
            return repos;
        }
    };
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) User(com.meisolsson.githubsdk.model.User) ThrowableLoader(com.github.pockethub.android.ThrowableLoader)

Example 22 with User

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

the class RepositoryListFragment method onOrganizationSelected.

@Override
public void onOrganizationSelected(final User organization) {
    User previousOrg = org.get();
    int previousOrgId = previousOrg != null ? previousOrg.id() : -1;
    org.set(organization);
    if (recentRepos != null) {
        recentRepos.saveAsync();
    }
    // Only hard refresh if view already created and org is changing
    if (previousOrgId != organization.id()) {
        Activity activity = getActivity();
        if (activity != null) {
            recentRepos = new RecentRepositories(activity, organization);
        }
        refreshWithProgress();
    }
}
Also used : User(com.meisolsson.githubsdk.model.User) Activity(android.app.Activity) UserViewActivity(com.github.pockethub.android.ui.user.UserViewActivity)

Example 23 with User

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

the class MainActivityTest method setup.

@Before
public void setup() {
    mockMainActivity = Robolectric.buildActivity(MockMainActivity.class).create().get();
    List<User> org = new ArrayList<>();
    org.add(User.builder().build());
    Account firstGitHubAccount = new Account("GitHubAccount", "com.github");
    Account secondGitHubAccount = new Account("GitHubAccount2", "com.github");
    accounts = new Account[] { firstGitHubAccount, secondGitHubAccount };
    mockManager = mock(AccountManager.class);
    when(mockManager.getAccountsByType(RuntimeEnvironment.application.getString(R.string.account_type))).thenReturn(accounts);
    mockMainActivity.onLoadFinished(null, org);
    argumentCaptor = ArgumentCaptor.forClass(Account.class);
}
Also used : Account(android.accounts.Account) User(com.meisolsson.githubsdk.model.User) ArrayList(java.util.ArrayList) AccountManager(android.accounts.AccountManager) Before(org.junit.Before)

Example 24 with User

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

the class IssuesFragment method updateFilterSummary.

private void updateFilterSummary() {
    if (filter.isOpen()) {
        state.setText(R.string.open_issues);
    } else {
        state.setText(R.string.closed_issues);
    }
    Collection<Label> filterLabels = filter.getLabels();
    if (filterLabels != null && !filterLabels.isEmpty()) {
        LabelDrawableSpan.setText(labels, filterLabels);
        labels.setVisibility(VISIBLE);
    } else {
        labels.setVisibility(GONE);
    }
    Milestone filterMilestone = filter.getMilestone();
    if (filterMilestone != null) {
        milestone.setText(filterMilestone.title());
        milestone.setVisibility(VISIBLE);
    } else {
        milestone.setVisibility(GONE);
    }
    User user = filter.getAssignee();
    if (user != null) {
        avatars.bind(assigneeAvatar, user);
        assignee.setText(user.login());
        assigneeArea.setVisibility(VISIBLE);
    } else {
        assigneeArea.setVisibility(GONE);
    }
}
Also used : User(com.meisolsson.githubsdk.model.User) Milestone(com.meisolsson.githubsdk.model.Milestone) Label(com.meisolsson.githubsdk.model.Label)

Example 25 with User

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

the class MembersFragment method onListItemClick.

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    User user = (User) l.getItemAtPosition(position);
    startActivity(UserViewActivity.createIntent(user));
}
Also used : User(com.meisolsson.githubsdk.model.User)

Aggregations

User (com.meisolsson.githubsdk.model.User)61 Repository (com.meisolsson.githubsdk.model.Repository)10 ActionBar (android.support.v7.app.ActionBar)6 ArrayList (java.util.ArrayList)5 Activity (android.app.Activity)4 RecentRepositories (com.github.pockethub.android.ui.repo.RecentRepositories)4 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)4 UserService (com.meisolsson.githubsdk.service.users.UserService)4 Bundle (android.os.Bundle)3 View (android.view.View)3 ListView (android.widget.ListView)3 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)3 ThrowableLoader (com.github.pockethub.android.ThrowableLoader)3 StyledText (com.github.pockethub.android.ui.StyledText)3 Label (com.meisolsson.githubsdk.model.Label)3 Milestone (com.meisolsson.githubsdk.model.Milestone)3 Account (android.accounts.Account)2 ContentValues (android.content.ContentValues)2 UiThreadTest (android.test.UiThreadTest)2 OnClickListener (android.view.View.OnClickListener)2