Search in sources :

Example 1 with MarvelCharacter

use of saulmm.avengers.entities.MarvelCharacter in project Avengers by saulmm.

the class CharacterListActivity method bindCharacterList.

@Override
public void bindCharacterList(List<MarvelCharacter> avengers) {
    mCharacterListAdapter = new AvengersListAdapter(avengers, this, (position, sharedView, characterImageView) -> {
        mAvengersListPresenter.onElementClick(position);
    });
    mAvengersRecycler.setAdapter(mCharacterListAdapter);
}
Also used : AvengersListAdapter(saulmm.avengers.views.adapter.AvengersListAdapter) Bundle(android.os.Bundle) MarvelCharacter(saulmm.avengers.entities.MarvelCharacter) ProgressBar(android.widget.ProgressBar) ButterKnife(butterknife.ButterKnife) Utils(saulmm.avengers.utils.Utils) OnScrollListener(android.support.v7.widget.RecyclerView.OnScrollListener) OnClick(butterknife.OnClick) Inject(javax.inject.Inject) ActivityOptions(android.app.ActivityOptions) View(android.view.View) Bind(butterknife.Bind) CharacterListView(saulmm.avengers.mvp.views.CharacterListView) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) ActivityModule(saulmm.avengers.injector.modules.ActivityModule) AvengersApplication(saulmm.avengers.AvengersApplication) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) AppCompatActivity(android.support.v7.app.AppCompatActivity) DaggerAvengersComponent(saulmm.avengers.injector.components.DaggerAvengersComponent) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar) R(saulmm.avengers.R) RecyclerInsetsDecoration(saulmm.avengers.views.views.RecyclerInsetsDecoration) CharacterListPresenter(saulmm.avengers.mvp.presenters.CharacterListPresenter) Snackbar(android.support.design.widget.Snackbar) AvengersListAdapter(saulmm.avengers.views.adapter.AvengersListAdapter)

Example 2 with MarvelCharacter

use of saulmm.avengers.entities.MarvelCharacter in project Avengers by saulmm.

the class ListPresenterTest method givenAFakeCharacterList.

private ArrayList<MarvelCharacter> givenAFakeCharacterList() {
    ArrayList<MarvelCharacter> marvelCharacters = new ArrayList<>();
    marvelCharacters.add(new MarvelCharacter("", -1));
    marvelCharacters.add(new MarvelCharacter("", -1));
    return marvelCharacters;
}
Also used : ArrayList(java.util.ArrayList) MarvelCharacter(saulmm.avengers.entities.MarvelCharacter)

Example 3 with MarvelCharacter

use of saulmm.avengers.entities.MarvelCharacter in project Avengers by saulmm.

the class ListPresenterTest method testThatCharactersArePassedToTheView.

@Test
public void testThatCharactersArePassedToTheView() throws Exception {
    CharacterListPresenter listPresenter = givenAListPresenter();
    ArrayList<MarvelCharacter> fakeCharacterList = givenAFakeCharacterList();
    listPresenter.onCharactersReceived(fakeCharacterList);
    verify(mockCharacterListView, times(1)).bindCharacterList(fakeCharacterList);
}
Also used : MarvelCharacter(saulmm.avengers.entities.MarvelCharacter) CharacterListPresenter(saulmm.avengers.mvp.presenters.CharacterListPresenter) Test(org.junit.Test)

Example 4 with MarvelCharacter

use of saulmm.avengers.entities.MarvelCharacter in project Avengers by saulmm.

the class GsonDeserializersTest method testThatACharacterDeseralizersDeserializesACharacter.

@Test
public void testThatACharacterDeseralizersDeserializesACharacter() throws Exception {
    MarvelResultsDeserializer<MarvelCharacter> marvelResultsDeserializer = new MarvelResultsDeserializer<>();
    JsonElement characterElement = new JsonParser().parse(getCharacterJsonString());
    Type t = new TypeToken<List<MarvelCharacter>>() {
    }.getType();
    List<MarvelCharacter> characterList = marvelResultsDeserializer.deserialize(characterElement, t, mock(JsonDeserializationContext.class));
    assertThat(characterList.isEmpty(), is(false));
    assertThat(characterList.get(0).getName(), is("3-D Man"));
}
Also used : Type(java.lang.reflect.Type) JsonDeserializationContext(com.google.gson.JsonDeserializationContext) JsonElement(com.google.gson.JsonElement) List(java.util.List) MarvelCharacter(saulmm.avengers.entities.MarvelCharacter) MarvelResultsDeserializer(saulmm.avengers.rest.utils.deserializers.MarvelResultsDeserializer) JsonParser(com.google.gson.JsonParser) Test(org.junit.Test)

Aggregations

MarvelCharacter (saulmm.avengers.entities.MarvelCharacter)4 List (java.util.List)2 Test (org.junit.Test)2 CharacterListPresenter (saulmm.avengers.mvp.presenters.CharacterListPresenter)2 ActivityOptions (android.app.ActivityOptions)1 Bundle (android.os.Bundle)1 CollapsingToolbarLayout (android.support.design.widget.CollapsingToolbarLayout)1 Snackbar (android.support.design.widget.Snackbar)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 OnScrollListener (android.support.v7.widget.RecyclerView.OnScrollListener)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 ProgressBar (android.widget.ProgressBar)1 TextView (android.widget.TextView)1 Bind (butterknife.Bind)1 ButterKnife (butterknife.ButterKnife)1 OnClick (butterknife.OnClick)1 JsonDeserializationContext (com.google.gson.JsonDeserializationContext)1