Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

rafaelcrz/themovie_android_wrapper

Repository files navigation

Themovie Android Wrapper

This is a wrapper for The Moviedb API version 3

This project uses the Retrofit to create interfaces from tmdb API endpoints.

This project is on development.

Endpoint available:

Movie

  • GetCatalog Movies (Popular, Playing now, Top rated)
  • Get Videos from movies
  • Get detail movie

Integrating into your project

This project is available in JitPack.io repository.

Add into build.gradle

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

Add into app/build.gradle

dependencies {
  compile 'com.github.rafaelcrz:themovie_android_wrapper:master-SNAPSHOT'
}

API KEY

How get the "Themoviedb" API KEY

Endpoints availables

Movie (popular, top rated and playing now movies)

Use it in the first param getMovieCatalog(<movieCategory>, <theMovieApiListener>)

TheMovieApi.NOW_PLAYING;
TheMovieApi.POPULAR;
TheMovieApi.TOP_RATED

Detail movie

Return a detail of specific movie

Video

Return a catalog video from a specific movie

Samples

Simple

  • Into this project has a simple sample, for get the Popular Movies.

Complete

Usage

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();
    }
});