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.moviedetails; // w w w . j ava 2s . c o m import com.jlmd.android.newfilmsmvp.api.mapper.Mapper; import com.jlmd.android.newfilmsmvp.api.moviedetails.MovieDetailsApi; import com.jlmd.android.newfilmsmvp.api.moviedetails.model.MovieDetailsResult; import com.jlmd.android.newfilmsmvp.domain.model.MovieDetails; import retrofit.RestAdapter; import retrofit.RetrofitError; import retrofit.client.Response; /** * @author jlmd */ public class RetrofitMovieDetailsApi implements MovieDetailsApi { private MovieDetailsService movieDetailsService; private final Mapper movieDetailsMapper; public RetrofitMovieDetailsApi(Mapper mapper) { this.movieDetailsMapper = mapper; initRestAdapter(); } private void initRestAdapter() { RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(BASE_URL) .build(); movieDetailsService = restAdapter.create(MovieDetailsService.class); } @Override public void getMovieDetails(int movieId, final Callback callback) { movieDetailsService.getMovieDetail(movieId, API_KEY, new retrofit.Callback<MovieDetailsResult>() { @Override public void success(MovieDetailsResult upcomingMoviesResults, Response response) { callback.onFinish((MovieDetails) movieDetailsMapper .map(upcomingMoviesResults)); } @Override public void failure(RetrofitError error) { callback.onError(error.getMessage()); } }); } }