This is a wrapper for The Moviedb API version 3
This project uses the Retrofit to create interfaces from tmdb API endpoints.
Movie
- GetCatalog Movies (Popular, Playing now, Top rated)
- Get Videos from movies
- Get detail movie
This project is available in JitPack.io repository.
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.rafaelcrz:themovie_android_wrapper:master-SNAPSHOT'
}
How get the "Themoviedb" API KEY
Use it in the first param getMovieCatalog(<movieCategory>, <theMovieApiListener>)
TheMovieApi.NOW_PLAYING;
TheMovieApi.POPULAR;
TheMovieApi.TOP_RATED
Return a detail of specific movie
Return a catalog video from a specific movie
- Into this project has a simple sample, for get the Popular Movies.
- It's a complete sample themoviedb_android_client using this wrapper.
Before you can use the TheMovieApi you must initialize the singleton.
You need put the TheMovieApplication into the AndroidManifest.xml
<application
android:name="com.github.rafaelcrz.tmdbandroidwrapper_lib.api.TheMovieApplication"
(...)
</application>
//Create a new instance for API
TheMovieApi theMovieApi = new TheMovieApi(mContext, "YOUR_API_KEY");
//Default lenguage is the local device
theMovieApi.setLanguage("pt-BR");
//Set the number page
theMovieApi.setPage("1"); //If you need do a infinit scroll set the page in the requests call
//Get a catalog movie
theMovieApi.getMovieCatalog(TheMovieApi.NOW_PLAYING, new TheMovieApiListener<MovieCatalog>() {
@Override
public void onResponse(Call<MovieCatalog> call, Response<MovieCatalog> movieResultResponse) {
if (movieResultResponse.isSuccessful()) {
MovieCatalog movieCatalog = movieResultResponse.body();
for (Movie movie : movieCatalog.getResults()) {
Log.i(TAG,movie.getTitle());
}
total_page = movieResultResponse.body().getTotal_pages(); //Total pages return from the API
}else{
Log.e(TAG,"HTTP_CODE -> "+movieResultResponse.code());
}
}
@Override
public void onFailure(Call<MovieCatalog> call, Throwable throwable) {
throwable.printStackTrace();
}
});