Search in sources :

Example 1 with RepositoryService

use of com.meisolsson.githubsdk.service.repositories.RepositoryService in project PocketHub by pockethub.

the class RepositoryContributorsFragment method onCreateLoader.

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

        @Override
        public List<User> loadData() throws Exception {
            RepositoryService service = ServiceGenerator.createService(getActivity(), RepositoryService.class);
            int current = 1;
            int last = 0;
            List<User> users = new ArrayList<>();
            while (current != last) {
                Page<User> page = service.getContributors(repo.owner().login(), repo.name(), current).blockingGet();
                users.addAll(page.items());
                last = page.last() != null ? page.last() : -1;
                current = page.next() != null ? page.next() : -1;
            }
            return users;
        }
    };
}
Also used : User(com.meisolsson.githubsdk.model.User) ArrayList(java.util.ArrayList) ThrowableLoader(com.github.pockethub.android.ThrowableLoader) RepositoryService(com.meisolsson.githubsdk.service.repositories.RepositoryService)

Aggregations

ThrowableLoader (com.github.pockethub.android.ThrowableLoader)1 User (com.meisolsson.githubsdk.model.User)1 RepositoryService (com.meisolsson.githubsdk.service.repositories.RepositoryService)1 ArrayList (java.util.ArrayList)1