package br.com.adley.whatsnextseries.activities;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import java.util.ArrayList;

import br.com.adley.whatsnextseries.R;
import br.com.adley.whatsnextseries.adapters.recyclerview.ListEpisodesRecyclerViewAdapter;
import br.com.adley.whatsnextseries.library.AppConsts;
import br.com.adley.whatsnextseries.models.remote.ApiUtils;
import br.com.adley.whatsnextseries.models.remote.TheMovieDBService;
import br.com.adley.whatsnextseries.models.retrofit.Episodes;
import br.com.adley.whatsnextseries.models.retrofit.SeasonEpisodes;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class EpisodesActivity extends BaseActivity {

    private TheMovieDBService mService;
    private RecyclerView mRecyclerViewEpisodes;
    private ListEpisodesRecyclerViewAdapter mEpisodesAdapter;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_episodes);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        // Get Intent Data
        int showId = getIntent().getIntExtra(AppConsts.SHOW_ID_INTENT, 0);
        int seasonNumber = getIntent().getIntExtra(AppConsts.SEASON_NUMBER_INTENT, 0);
        String tvShowName = getIntent().getStringExtra(AppConsts.SHOW_NAME_INTENT);

        // Change Toolbar Title
        getSupportActionBar().setTitle(getString(R.string.title_activity_season_episodes) + " - " + tvShowName);
        mRecyclerViewEpisodes = (RecyclerView) findViewById(R.id.recycler_view_episodes_list);
        mRecyclerViewEpisodes.setLayoutManager(new LinearLayoutManager(this));
        mEpisodesAdapter = new ListEpisodesRecyclerViewAdapter(EpisodesActivity.this, new ArrayList<Episodes>());
        mRecyclerViewEpisodes.setAdapter(mEpisodesAdapter);

        // Load shared Configs
        loadConfigPreferences(this);

        String languageSelected = isLanguageUsePtBr() ? "pt-BR" : "en-US";
        mService = ApiUtils.getTMDBService(getString(R.string.url_base));
        mService.getEpisodesSeason(String.valueOf(showId), (String.valueOf(seasonNumber)), getString(R.string.api_key), languageSelected).enqueue(new Callback<SeasonEpisodes>() {
            @Override
            public void onResponse(Call<SeasonEpisodes> call, Response<SeasonEpisodes> response) {
                if (response.isSuccessful()){
                    Log.d("TAG_TESTE", "Season name: " + response.body().getName());
                    if (response.body() != null && response.body().getEpisodes() != null) {
                        mEpisodesAdapter.loadNewData(response.body().getEpisodes());
                    }

                }else{
                    Log.e("TAG_TESTE", String.valueOf(response.code()));
                }
            }

            @Override
            public void onFailure(Call<SeasonEpisodes> call, Throwable t) {
                Log.e("TAG_TESTE", String.valueOf(t.getMessage()));
            }
        });

    }

}

@@ -69,16 +69,68 @@
 Bundle;%0A
+import android.support.v7.widget.GridLayoutManager;%0A
 import a
@@ -167,32 +167,32 @@
 rLayoutManager;%0A
-
 import android.s
@@ -504,16 +504,67 @@
 Consts;%0A
+import br.com.adley.whatsnextseries.library.Utils;%0A
 import b
@@ -1948,16 +1948,149 @@
 _list);%0A
+        if(Utils.isTablet(this))%0A            mRecyclerViewEpisodes.setLayoutManager(new GridLayoutManager(this,2));%0A        else%0A    
         
@@ -2156,24 +2156,24 @@
 ger(this));%0A
-
         mEpi
@@ -2903,93 +2903,8 @@
 ))%7B%0A
-                    Log.d(%22TAG_TESTE%22, %22Season name: %22 + response.body().getName());%0A
     
@@ -3072,24 +3072,24 @@
 pisodes());%0A
+
             
@@ -3101,105 +3101,8 @@
    %7D
-%0A%0A                %7Delse%7B%0A                    Log.e(%22TAG_TESTE%22, String.valueOf(response.code()));
 %0A   

Add gridlayout for episodes list.