Created
January 15, 2017 07:46
-
-
Save travisdachi/2b8ae2184d60e20771e9ad268ee3070b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomePresenter implements HomeContract.HomePresenter { | |
private HomeContract.HomeView view; | |
private StarWarsApi starWarsApi; | |
public HomePresenter(HomeContract.HomeView view) { | |
this.view = view; | |
starWarsApi = Apis.getSwarWarsApi(); | |
view.showTitle("All Star Wars Films"); | |
} | |
@Override | |
public void getAllFilms() { | |
view.showLoading(); | |
starWarsApi.getAllFilms().enqueue(new Callback<FilmResponse>() { | |
@Override | |
public void onResponse(Call<FilmResponse> call, Response<FilmResponse> response) { | |
view.showAllFilms(response.body().results); | |
view.hideLoading(); | |
} | |
@Override | |
public void onFailure(Call<FilmResponse> call, Throwable t) { | |
view.showMessage(t.getMessage()); | |
view.hideLoading(); | |
} | |
}); | |
} | |
@Override | |
public void onFilmItemClicked(Film film) { | |
view.navigateToFilmPage(film); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment