TheMovieDb API – Part 4 – The Movie Presenter

Welcome back to this series on implementing TheMovieDb API. As always remember all the code for this series will be in this GitHub repo today we are going to setup and test our Movie Presenter, remember the MVP pattern? Awesome so let’s get right to it!

First let’s define what we want to do with a simple interface. We need to be able from the View to: show the progress bar, show details of the movie later on, set the movie lists to our adapter, clear movies out and show messages. So it should look something like:

public interface MoviesContract {
     * Represents the methods that our view (Activity or Fragment)
     * will implement.
    interface View {

        void showProgressBar(boolean active);

        void showMovieDetailUi(Bundle movieArgs);

        void setMovies(List<Movie> movies);

        void clearMovies();

        void showMessage(String msg, int duration);

Continue reading “TheMovieDb API – Part 4 – The Movie Presenter”

TheMovieDb API – Part 2 – Setting up Retrofit

Welcome back to implementing TheMovieDb API. As always remember all the code for this series will be in this GitHub repo today we are covering the popular type safe http client for Android called Retrofit. Retrofit allows us to turn out HTTP APIs into Java interfaces easy.

Now the first thing we need to make sure is that, since we are connecting to a web service, is that we have the INTERNET permission under our AndroidManifest.xml go ahead a place it like this:

<uses-permission android:name="android.permission.INTERNET" />

Once you have that cover let’s start by creating an ApiClient class that will serve as our “service generator” for the various endpoint options available from the API. Under app/src/main/java/your.package/ create a new class and place the following: Continue reading “TheMovieDb API – Part 2 – Setting up Retrofit”

TheMovieDb API – Part 1

It’s API time and TheMovieDb api is one of the best for learning and building an android application that connects to a REST service, saves offline through a Content Provider and can be unit tested thoroughly.

We will do it by parts so everyone can enjoy the full ride. I will assume you have already install Android Studio 2.0 from the official website. The code will be on this GitHub repo so you can view/download/doItYourself on the go.

First we will do a super refresh and create our android project, go ahead and launch Android Studio and click “Start a new Android Studio Project”

Android Studio
Android Studio

Continue reading “TheMovieDb API – Part 1”