use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.
the class ComicSeriesApiDataSource method getByKey.
@Override
public ComicSeries getByKey(Integer key) throws Exception {
MarvelResponse<SeriesDto> seriesResponse = seriesApiClient.getSeriesById(key.toString());
SeriesDto seriesDto = seriesResponse.getResponse();
ComicSeries comicSeries = mapper.reverseMap(seriesDto);
return comicSeries;
}
use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.
the class ComicSeriesFakeDataSource method getByKey.
@Override
public ComicSeries getByKey(Integer key) {
ComicSeries comicSeries;
fakeDelay();
switch(key) {
case GUARDIANS_OF_INFINITY_KEY:
comicSeries = getGuardiansOfInfinity();
break;
case VISION_KEY:
comicSeries = getVision();
break;
case SPIDEY_KEY:
comicSeries = getSpidey();
break;
case RED_WOLF_KEY:
comicSeries = getRedWolf();
break;
case NOVA_KEY:
default:
comicSeries = getNova();
break;
}
return comicSeries;
}
use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.
the class ComicSeriesToComicSeriesViewModelMapper method mapComicSeriesToComicSeriesViewModels.
public List<ComicSeriesViewModel> mapComicSeriesToComicSeriesViewModels(PaginatedCollection<ComicSeries> comics) {
List<ComicSeriesViewModel> comicSeriesViewModels = new LinkedList<>();
for (ComicSeries comicSeries : comics.getItems()) {
ComicSeriesViewModel comicSeriesViewModel = new ComicSeriesViewModel();
comicSeriesViewModel.setKey(comicSeries.getKey());
String titleFormatted = String.format("%1$s (%2$s)", comicSeries.getName(), comicSeries.getReleaseYear());
comicSeriesViewModel.setTitle(titleFormatted);
comicSeriesViewModel.setCoverUrl(comicSeries.getCoverUrl());
comicSeriesViewModels.add(comicSeriesViewModel);
}
return comicSeriesViewModels;
}
use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.
the class ComicSeriesToSeriesDtoMapper method reverseMap.
@Override
public ComicSeries reverseMap(SeriesDto value) {
ComicSeries comicSeries = new ComicSeries();
comicSeries.setDescription(value.getDescription());
comicSeries.setName(value.getTitle());
comicSeries.setKey(Integer.valueOf(value.getId()));
comicSeries.setReleaseYear(value.getStartYear());
comicSeries.setCoverUrl(value.getThumbnail().getImageUrl(MarvelImage.Size.PORTRAIT_UNCANNY));
comicSeries.setRating(value.getRating());
List<Comic> comics = new ArrayList<>();
comicSeries.setComics(comics);
return comicSeries;
}
use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.
the class GetComicSeriesPage method getAllComicsInCache.
public PaginatedCollection<ComicSeries> getAllComicsInCache() {
Collection<ComicSeries> all;
try {
all = repository.getAll(ReadPolicy.CACHE_ONLY);
} catch (Exception e) {
all = new ArrayList<>();
}
if (all == null) {
all = new ArrayList<>();
}
Page page = Page.withOffsetAndLimit(0, all.size());
PaginatedCollection<ComicSeries> comics = new PaginatedCollection<>(all);
comics.setPage(page);
comics.setHasMore(true);
return comics;
}
Aggregations