use of com.karumi.rosie.repository.PaginatedCollection in project Rosie by Karumi.
the class CharactersApiDataSource method getPage.
@Override
public PaginatedCollection<Character> getPage(Page page) throws MarvelApiException {
int offset = page.getOffset();
int limit = page.getLimit();
MarvelResponse<CharactersDto> charactersApiResponse = characterApiClient.getAll(offset, limit);
CharactersDto charactersDto = charactersApiResponse.getResponse();
Collection<Character> characters = mapper.reverseMap(charactersDto.getCharacters());
PaginatedCollection<Character> charactersPage = new PaginatedCollection<>(characters);
charactersPage.setPage(page);
charactersPage.setHasMore(charactersDto.getOffset() + charactersDto.getCount() < charactersDto.getTotal());
return charactersPage;
}
Aggregations