TheMovieDb API – Part 8 – Show me more info!

Quickly open android studio! 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 setting base to show off movie details!

Let’s begin! First since we are doing test driven development we want to keep our implementation separate, in other words, business logic outside of the UI. Create a MovieDetailsContract interface with the following:

public interface MovieDetailsContract {

    interface View {

        void setMoviePoster(String moviePoster);

        void setMovieBackdropImage(String backdropImage);

        void setTitle(String title);

        void setOverview(String overview);

        void setPopularity(Double popularity);

        void setReleaseDate(String releaseDate);
    }

    interface UserActionsListener {
        void showMovieDetails();
    }
}

Continue reading “TheMovieDb API – Part 8 – Show me more info!”

TheMovieDb API – Part 7 – Load and show

It’s finally time! 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 taking all the building blocks created in previous posts and finally begin to show up the good stuff. Let’s get started!

First let’s create the fragment that will implement our MoviesContract.View that we created previously. Go ahead and use, if possible, the built in Fragment template leave the create resource/layout view option marked so Android Studio automatically generates it for you. Now you will have two new things one class representing your Fragment and a new layout.xml file for it. Here are mine:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.jrosa.moviezone.MoviesFragment">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/movies_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:listitem="@layout/movie_view" />

    <ProgressBar
        android:id="@+id/progress_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

</FrameLayout>

Continue reading “TheMovieDb API – Part 7 – Load and show”

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”