Tablet UI not working
<p>I am working on an app that presents a grid of popular movies to the users and when the user clicks on one of the items, it shows the details of the movie.</p>

<p>The app is working fine on phones but my tablet UI implementation is not working</p>

<p><strong>I don't get any crashes</strong> as such it's just that when I tap on a movie, the <strong>Details don't show up on tablets.</strong></p>

<p><strong>Here's the link to the GitHub repo</strong> - <a href="https://github.com/Hackertronix/Project-Motion/tree/Stage_2?files=1" rel="nofollow">https://github.com/Hackertronix/Project-Motion/tree/Stage_2?files=1</a></p>

<p><strong>And here are the files which concern with the Tablet UI</strong></p>

<p><strong>activity_movies.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/viewpager_container"&gt;

&lt;/FrameLayout&gt;
</code></pre>

<p><strong>activity_movies.xml (layout-sw600dp )</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="match_parent"
             android:layout_height="match_parent"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"&gt;

        &lt;FrameLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:id="@+id/viewpager_container"&gt;
        &lt;FrameLayout
            android:id="@+id/details_container"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            &gt;
        &lt;/FrameLayout&gt;
        &lt;/FrameLayout&gt;
    &lt;/LinearLayout&gt;

&lt;/FrameLayout&gt;
</code></pre>

<p><strong>MoviesActivity.java</strong></p>

<pre><code>package com.execube.genesis.views.activities;

import android.app.ActivityOptions;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.transition.Explode;
import android.view.View;


import com.execube.genesis.R;
import com.execube.genesis.model.Movie;
import com.execube.genesis.views.fragments.DetailsFragment;
import com.execube.genesis.views.fragments.PopularMoviesFragment;
import com.execube.genesis.views.fragments.TopRatedMoviesFragment;
import com.execube.genesis.views.fragments.ViewPagerFragment;


public class MoviesActivity extends AppCompatActivity implements PopularMoviesFragment.openDetailsListener,
        TopRatedMoviesFragment.openDetailsListener{


    boolean isTablet;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_movies);


        if (findViewById(R.id.details_container) == null)//CHECKING FOR TABLET CONFIGURATION
        {
            isTablet=false;
        }
        else{
            isTablet=true;
        }
        View view= findViewById(R.id.viewpager_container);

        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
            view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }

        if (Build.VERSION.SDK_INT &gt;= 21) {
            getWindow().setExitTransition(new Explode());
        }
        FragmentManager fragmentManager= getSupportFragmentManager();
        Fragment fragment;
        fragmentManager.findFragmentById(R.id.viewpager_container);

        if(savedInstanceState==null)
        {
            fragment= new ViewPagerFragment();
            fragmentManager.beginTransaction()
                    .add(R.id.viewpager_container,fragment)
                    .commit();

        }


    }

    @Override
    public void openDetails(Movie movie,ActivityOptions options) {

        //options parameter is for the transition

        if(isTablet)
        {
           //TODO Retain the transitions.

          Bundle bundle=new Bundle();
            bundle.putParcelable("PARCEL",movie);

            DetailsFragment fragment= new DetailsFragment();
            fragment.setArguments(bundle);

            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.details_container,fragment)
                    .commit();
}

        else{
            Intent intent= new Intent(this,DetailsActivity.class);
            intent.putExtra("PARCEL",movie);
            startActivity(intent,options.toBundle());
        }

    }
}
</code></pre>

<p><strong>DetailsActivity.java</strong></p>

<pre><code>package com.execube.genesis.views.activities;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.transition.Fade;
import android.transition.Slide;
import android.view.Gravity;
import android.view.View;

import com.execube.genesis.R;
import com.execube.genesis.views.fragments.DetailsFragment;

/**
 * Created by Prateek Phoenix on 5/1/2016.
 */
public class DetailsActivity extends FragmentActivity {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_details);


        if (Build.VERSION.SDK_INT &gt;= 21) {
            getWindow().setStatusBarColor(getResources().getColor(R.color.details_status_bar));
            Slide slide=new Slide(Gravity.BOTTOM);
            slide.excludeTarget(android.R.id.statusBarBackground,true);
            slide.excludeTarget(android.R.id.navigationBarBackground,true);
            getWindow().setEnterTransition(slide);
            postponeEnterTransition();
        }

        FragmentManager fragmentManager= getSupportFragmentManager();
        Fragment fragment= fragmentManager.findFragmentById(R.id.details_container);

        if(fragment==null)
        {
            Bundle arguments = new Bundle();
            arguments.putParcelable("PARCEL",
                    getIntent().getParcelableExtra("PARCEL"));

            fragment = new DetailsFragment();
            fragment.setArguments(arguments);
            fragmentManager.beginTransaction()
                    .add(R.id.details_container,fragment)
                    .commit();

        }

    }
}
</code></pre>

<p><strong>DetailsFragment.java</strong></p>

<pre><code>package com.execube.genesis.views.fragments;

import android.annotation.TargetApi;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.execube.genesis.R;
import com.execube.genesis.model.Movie;
import com.execube.genesis.model.Review;
import com.execube.genesis.utils.API;
import com.execube.genesis.utils.OkHttpHandler;
import com.squareup.picasso.Picasso;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;

import okhttp3.Call;
import okhttp3.Response;


/**
 * Created by Prateek Phoenix on 4/30/2016.
 */
public class DetailsFragment extends Fragment {
    private static final String TAG = "DETAILS";
    private static final int DEFAULT_NUM_COLORS = 5;
    private Movie mMovie;
    public Intent intent;

    private TextView mDetailTitle;
    private TextView mReleaseDate;
    private TextView mOverview;
    private TextView mOverviewHeader;


    private ImageView mBackdrop;
    private Toolbar mToolbar;

    private RatingBar mRatingBar;

    private ArrayList&lt;Review&gt; mReviews;


    public DetailsFragment() {

    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_detail, container, false);


        mBackdrop = (ImageView) view.findViewById(R.id.details_poster);
        mToolbar = (Toolbar) view.findViewById(R.id.toolbar);

        mDetailTitle = (TextView) view.findViewById(R.id.detail_title_text);
        mReleaseDate = (TextView) view.findViewById(R.id.release_date);
        mOverview = (TextView) view.findViewById(R.id.overview);
        mOverviewHeader = (TextView) view.findViewById(R.id.overview_header);

        mRatingBar = (RatingBar) view.findViewById(R.id.movie_rating);


        Bundle bundle=getArguments();
        mMovie=bundle.getParcelable("PARCEL");


        String id = String.valueOf(mMovie.getId());
        String reviewQueryUrl = API.MOVIES_BASE_URL + id + "/reviews" + API.API_KEY;
        String trailerQueryUrl = API.MOVIES_BASE_URL+id+"/videos"+API.API_KEY;

        mDetailTitle.setText(mMovie.getTitle());
        mReleaseDate.setText(mMovie.getReleaseDate());
        mRatingBar.setProgress((int) mMovie.getVoteAverage());
        mOverview.setText(mMovie.getOverview());


        if (Build.VERSION.SDK_INT != 21) {
            Typeface fontBold = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Gotham-Rounded-Bold.ttf");
            Typeface fontMedium = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Gotham-Rounded-Medium.ttf");
            Typeface fontMediumLight = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Gotham-Rounded-Book_.ttf");


            mDetailTitle.setTypeface(fontBold);
            mReleaseDate.setTypeface(fontMedium);
            mOverview.setTypeface(fontMediumLight);
            mOverviewHeader.setTypeface(fontBold);
        }


        OkHttpHandler handler = new OkHttpHandler(reviewQueryUrl, mCallback);
        handler.fetchData();

        Picasso.with(getActivity()).load(API.IMAGE_URL + API.IMAGE_SIZE_500 + mMovie.getPosterPath())
                .into(mBackdrop);
        getActivity().startPostponedEnterTransition();


        return view;
    }

    private okhttp3.Callback mCallback = new okhttp3.Callback() {
        @Override
        public void onFailure(Call call, IOException e) {
            //TODO handle failure on UI thread
        }

        @Override
        public void onResponse(Call call, Response response) throws IOException,IllegalStateException{

            try {
                String jsonResponse= response.body().string();
                Log.v(TAG,jsonResponse );
                JSONObject jsonObject = new JSONObject(jsonResponse);
                int resultCount = jsonObject.getInt("total_results");
                if (resultCount != 0) {
                    mReviews = parseReviews(jsonObject);
                } else
                    mReviews = null;

            } catch (JSONException e) {

            }
            catch (IllegalStateException e){}
        }
    };

    private ArrayList&lt;Review&gt; parseReviews(JSONObject jsonObject) throws JSONException {


        ArrayList&lt;Review&gt; Reviews = new ArrayList&lt;&gt;();
        JSONArray reviewsJSONArray = jsonObject.getJSONArray("results");

        for (int i = 0; i &lt; reviewsJSONArray.length(); i++) {

            Review review = new Review();
            JSONObject reviewJson = reviewsJSONArray.getJSONObject(i);

            review.setId(reviewJson.getInt("id"));
            review.setAuthor(reviewJson.getString("author"));
            review.setContent(reviewJson.getString("content"));
            review.setTotalResults(reviewJson.getInt("total_results"));

            Reviews.add(review);
        }

        return Reviews;
    }


}
</code></pre>