use of com.github.pockethub.android.ThrowableLoader 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;
}
};
}
use of com.github.pockethub.android.ThrowableLoader 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;
}
};
}
use of com.github.pockethub.android.ThrowableLoader in project PocketHub by pockethub.
the class SearchIssueListFragment method onCreateLoader.
@Override
public Loader<List<Issue>> onCreateLoader(int id, Bundle args) {
return new ThrowableLoader<List<Issue>>(getActivity(), items) {
@Override
public List<Issue> loadData() throws Exception {
if (repository == null) {
return Collections.emptyList();
}
List<Issue> matches = new ArrayList<>();
SearchService service = ServiceGenerator.createService(getActivity(), SearchService.class);
int current = 1;
int last = 0;
while (current != last) {
SearchPage<Issue> page = service.searchIssues(query, null, null, current).blockingGet();
matches.addAll(page.items());
last = page.last() != null ? page.last() : -1;
current = page.next() != null ? page.next() : -1;
}
Collections.sort(matches, SearchIssueListFragment.this);
return matches;
}
};
}
use of com.github.pockethub.android.ThrowableLoader in project PocketHub by pockethub.
the class MembersFragment 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 {
OrganizationMemberService service = ServiceGenerator.createService(getContext(), OrganizationMemberService.class);
int current = 1;
int last = -1;
List<User> users = new ArrayList<>();
while (current != last) {
Page<User> page = service.getMembers(org.login(), current).blockingGet();
users.addAll(page.items());
last = page.last() != null ? page.last() : -1;
current = page.next() != null ? page.next() : -1;
}
return users;
}
};
}
Aggregations