Back to project page UpcomingMoviesMVP.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Defi...
If you think the Android project UpcomingMoviesMVP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jlmd.android.newfilmsmvp.api.retrofit.upcomingmovies; // w w w.j ava 2 s . c o m import com.jlmd.android.newfilmsmvp.api.mapper.Mapper; import com.jlmd.android.newfilmsmvp.api.upcomingmovies.UpcomingMoviesApi; import com.jlmd.android.newfilmsmvp.api.upcomingmovies.model.UpcomingMoviesResult; import com.jlmd.android.newfilmsmvp.domain.model.Movie; import java.util.List; import retrofit.RestAdapter; import retrofit.RetrofitError; import retrofit.client.Response; /** * @author jlmd */ public class RetrofitUpcomingMoviesApi implements UpcomingMoviesApi { private UpcomingMoviesService upcomingMoviesService; private final Mapper upcomingMoviesApiMapper; public RetrofitUpcomingMoviesApi(Mapper mapper) { this.upcomingMoviesApiMapper = mapper; initRestAdapter(); } private void initRestAdapter() { RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(BASE_URL) .build(); upcomingMoviesService = restAdapter.create(UpcomingMoviesService.class); } @Override public void getUpcomingMovies(final Callback callback) { upcomingMoviesService.getUpcomingMovies(API_KEY, new retrofit.Callback<UpcomingMoviesResult>() { @Override public void success(UpcomingMoviesResult upcomingMoviesResults, Response response) { callback.onFinish((List<Movie>) upcomingMoviesApiMapper.map(upcomingMoviesResults)); } @Override public void failure(RetrofitError error) { callback.onError(error.getMessage()); } }); } }