Search in sources :

Example 11 with ComicSeries

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;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) SeriesDto(com.karumi.marvelapiclient.model.SeriesDto)

Example 12 with 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;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries)

Example 13 with 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;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) ComicSeriesViewModel(com.karumi.rosie.sample.comics.view.viewmodel.ComicSeriesViewModel) LinkedList(java.util.LinkedList)

Example 14 with ComicSeries

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;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) ArrayList(java.util.ArrayList) Comic(com.karumi.rosie.sample.comics.domain.model.Comic)

Example 15 with 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;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) ArrayList(java.util.ArrayList) Page(com.karumi.rosie.repository.datasource.paginated.Page) PaginatedCollection(com.karumi.rosie.repository.PaginatedCollection)

Aggregations

ComicSeries (com.karumi.rosie.sample.comics.domain.model.ComicSeries)22 NonNull (android.support.annotation.NonNull)7 PaginatedCollection (com.karumi.rosie.repository.PaginatedCollection)3 InjectedInstrumentationTest (com.karumi.rosie.sample.InjectedInstrumentationTest)3 Comic (com.karumi.rosie.sample.comics.domain.model.Comic)3 Test (org.junit.Test)3 Page (com.karumi.rosie.repository.datasource.paginated.Page)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Activity (android.app.Activity)1 ViewPager (android.support.v4.view.ViewPager)1 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 SeriesCollectionDto (com.karumi.marvelapiclient.model.SeriesCollectionDto)1 SeriesDto (com.karumi.marvelapiclient.model.SeriesDto)1 RosieUseCase (com.karumi.rosie.domain.usecase.RosieUseCase)1 UseCase (com.karumi.rosie.domain.usecase.annotation.UseCase)1 CharacterDetailsActivity (com.karumi.rosie.sample.characters.view.activity.CharacterDetailsActivity)1 ComicSeriesDetailsActivity (com.karumi.rosie.sample.comics.view.activity.ComicSeriesDetailsActivity)1 ComicSeriesDetailViewModel (com.karumi.rosie.sample.comics.view.viewmodel.ComicSeriesDetailViewModel)1 ComicSeriesViewModel (com.karumi.rosie.sample.comics.view.viewmodel.ComicSeriesViewModel)1