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
| // Fetch a single movie by id | |
| private void fetchMovieByID(int movieId) { | |
| final Call<Movie> call = mService.getMovieWithId(movieId, BuildConfig.TMDB_API_KEY); | |
| call.enqueue(new Callback<Movie>() { | |
| @Override | |
| public void onResponse(Call<Movie> call, Response<Movie> response) { | |
| movie = response.body(); | |
| // Do sth with movie instance | |
| // Like : movieTitleTextView.setText(movie.getTitle()); |
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
| { | |
| "adult": false, | |
| "backdrop_path": "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg", | |
| "belongs_to_collection": null, | |
| "budget": 63000000, | |
| "genres": [ | |
| { | |
| "id": 18, | |
| "name": "Drama" | |
| } |
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 interface MovieService { | |
| //Get a movie | |
| @GET("movie/{id}") | |
| Call<Movie> getMovieWithId(@Path("id") int movieId, @Query("api_key") String api_key); | |
| } |
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 HttpClient { | |
| private final static String BASE_URL = "https://api.themoviedb.org/3/"; | |
| public final MovieService mMovieService; | |
| public HttpClient() { | |
| Retrofit retrofit = new Retrofit.Builder() | |
| .baseUrl(BASE_URL) | |
| .addConverterFactory(GsonConverterFactory.create()) | |
| .build(); |
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
| android { | |
| /*...*/ | |
| buildTypes.each { | |
| it.buildConfigField 'String', 'TMDB_API_KEY', TmdbBApiKey | |
| } | |
| } |
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
| dependencies { | |
| implementation 'com.android.support:appcompat-v7:27.1.0' | |
| implementation 'com.android.support:cardview-v7:27.1.0' | |
| implementation 'com.android.support:design:27.1.0' | |
| implementation 'com.android.support.constraint:constraint-layout:1.0.2' | |
| implementation 'com.android.support:support-v4:27.1.0' | |
| implementation 'com.android.support:transition:27.1.0' | |
| compile 'com.squareup.retrofit2:retrofit:2.3.0' | |
| compile 'com.squareup.retrofit2:converter-gson:2.3.0' | |
| compile 'com.squareup.picasso:picasso:2.5.2' |
NewerOlder