Skip to content

Instantly share code, notes, and snippets.

@travisdachi
Created January 15, 2017 07:46
Show Gist options
  • Save travisdachi/2b8ae2184d60e20771e9ad268ee3070b to your computer and use it in GitHub Desktop.
Save travisdachi/2b8ae2184d60e20771e9ad268ee3070b to your computer and use it in GitHub Desktop.
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