/*
 * Copyright (C) 2017 Angel Garcia
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xengar.android.movieguide.ui;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;

import com.xengar.android.movieguide.R;
import com.xengar.android.movieguide.utils.ActivityUtils;

import static com.xengar.android.movieguide.utils.Constants.LAST_ACTIVITY;
import static com.xengar.android.movieguide.utils.Constants.TV_SHOW_ACTIVITY;

public class TVShowActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tvshow);

        // Save name of activity, in case of calling SettingsActivity
        ActivityUtils.saveStringToPreferences(getApplicationContext(), LAST_ACTIVITY,
                TV_SHOW_ACTIVITY);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        ActivityUtils.loadNoBackgroundPoster(getApplicationContext(),
                (ImageView) findViewById(R.id.background_poster));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            ActivityUtils.launchSettingsActivity(getApplicationContext());
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

@@ -656,17 +656,172 @@
 oid.
-os.Bundle
+content.SharedPreferences;%0Aimport android.os.Bundle;%0Aimport android.support.design.widget.AppBarLayout;%0Aimport android.support.design.widget.CollapsingToolbarLayout
 ;%0Aim
@@ -1369,82 +1369,438 @@
 nts.
-TV_SHOW_ACTIVITY;%0A%0Apublic class TVShowActivity extends AppCompatActivity %7B
+SHARED_PREF_NAME;%0Aimport static com.xengar.android.movieguide.utils.Constants.TV_SHOW_ACTIVITY;%0Aimport static com.xengar.android.movieguide.utils.Constants.TV_SHOW_ID;%0A%0Apublic class TVShowActivity extends AppCompatActivity %7B%0A%0A    private static final String TAG = TVShowActivity.class.getSimpleName();%0A    private int tvShowId;%0A    private CollapsingToolbarLayout collapsingToolbar;%0A    private final String%5B%5D tvShowTitle = %7B%22 %22%7D;
 %0A%0A  
@@ -2317,24 +2317,194 @@
 led(true);%0A%0A
+        SharedPreferences prefs = getSharedPreferences(SHARED_PREF_NAME, 0);%0A        tvShowId = prefs.getInt(TV_SHOW_ID, -1);%0A        tvShowTitle%5B0%5D = %22Sample TV Show%22;%0A%0A
         Floa
@@ -3009,24 +3009,269 @@
 d_poster));%0A
+        collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);%0A        ActivityUtils.changeCollapsingToolbarLayoutBehaviour(collapsingToolbar,%0A                (AppBarLayout) findViewById(R.id.appbar), tvShowTitle);%0A
     %7D%0A%0A    @

Add collapsing Toolbar behaviour to TVShow page