Search in sources :

Example 1 with CharacterDetailViewModel

use of com.karumi.rosie.sample.characters.view.viewmodel.CharacterDetailViewModel in project Rosie by Karumi.

the class CharacterToCharacterDetailViewModelMapper method mapCharacterToCharacterDetailViewModel.

public CharacterDetailViewModel mapCharacterToCharacterDetailViewModel(Character character) {
    CharacterDetailViewModel characterViewModel = new CharacterDetailViewModel();
    characterViewModel.setKey(character.getKey());
    characterViewModel.setName(character.getName());
    characterViewModel.setHeaderImage(character.getThumbnailUrl());
    characterViewModel.setDescription(character.getDescription());
    return characterViewModel;
}
Also used : CharacterDetailViewModel(com.karumi.rosie.sample.characters.view.viewmodel.CharacterDetailViewModel)

Example 2 with CharacterDetailViewModel

use of com.karumi.rosie.sample.characters.view.viewmodel.CharacterDetailViewModel in project Rosie by Karumi.

the class CharacterDetailsPresenter method loadCharacterDetails.

private void loadCharacterDetails() {
    getView().hideCharacterDetail();
    createUseCaseCall(getCharacterDetails).args(characterKey).onSuccess(new OnSuccessCallback() {

        @Success
        public void onCharacterDetailsLoaded(Character character) {
            hideLoading();
            CharacterDetailViewModel characterDetailViewModel = mapper.mapCharacterToCharacterDetailViewModel(character);
            getView().showCharacterDetail(characterDetailViewModel);
        }
    }).onError(new OnErrorCallback() {

        @Override
        public boolean onError(Error error) {
            getView().hideLoading();
            return false;
        }
    }).execute();
}
Also used : OnErrorCallback(com.karumi.rosie.domain.usecase.error.OnErrorCallback) Character(com.karumi.rosie.sample.characters.domain.model.Character) CharacterDetailViewModel(com.karumi.rosie.sample.characters.view.viewmodel.CharacterDetailViewModel) OnSuccessCallback(com.karumi.rosie.domain.usecase.callback.OnSuccessCallback) Success(com.karumi.rosie.domain.usecase.annotation.Success)

Aggregations

CharacterDetailViewModel (com.karumi.rosie.sample.characters.view.viewmodel.CharacterDetailViewModel)2 Success (com.karumi.rosie.domain.usecase.annotation.Success)1 OnSuccessCallback (com.karumi.rosie.domain.usecase.callback.OnSuccessCallback)1 OnErrorCallback (com.karumi.rosie.domain.usecase.error.OnErrorCallback)1 Character (com.karumi.rosie.sample.characters.domain.model.Character)1