package com.xurxodev.moviesandroidkata.presentation.view.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.fragment.MovieDetailFragment;

public class MovieDetailActivity extends AppCompatActivity {

    public static final String MOVIE_TITLE = "MovieTitle";

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

        initializeToolBar();

        if (savedInstanceState == null) {
            showDetailFragment();
        }
    }

    private void showDetailFragment() {
        String movieTitle = (String) getIntent().getStringExtra(MovieDetailActivity.MOVIE_TITLE);

        Bundle arguments = new Bundle();
        arguments.putSerializable(MovieDetailActivity.MOVIE_TITLE, movieTitle);

        MovieDetailFragment fragment = new MovieDetailFragment();

        fragment.setArguments(arguments);

        getSupportFragmentManager().beginTransaction()
                .add(R.id.movie_detail_container, fragment)
                .commit();
    }

    private void initializeToolBar() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }

    public static Intent createIntent(Context context, String movieTitle) {
        Intent intent = new Intent(context, MovieDetailActivity.class);

        intent.putExtra(MOVIE_TITLE, movieTitle);

        return intent;
    }
}

@@ -150,16 +150,57 @@
 Bundle;%0A
+import android.support.v7.app.ActionBar;%0A
 import a
@@ -281,16 +281,46 @@
 Toolbar;
+%0Aimport android.view.MenuItem;
 %0A%0Aimport
@@ -763,16 +763,51 @@
 olBar();
+%0A        showUpButtonInActionBar();
 %0A%0A      
@@ -1506,16 +1506,23 @@
 Id(R.id.
+detail_
 toolbar)
@@ -1564,24 +1564,227 @@
 ar);%0A    %7D%0A%0A
+    private void showUpButtonInActionBar() %7B%0A        ActionBar actionBar = getSupportActionBar();%0A        if (actionBar != null) %7B%0A            actionBar.setDisplayHomeAsUpEnabled(true);%0A        %7D%0A    %7D%0A%0A
     public s
@@ -1999,11 +1999,296 @@
 t;%0A    %7D
+%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        int id = item.getItemId();%0A%0A        if (id == android.R.id.home) %7B%0A            supportFinishAfterTransition();%0A%0A            return true;%0A        %7D%0A        return super.onOptionsItemSelected(item);%0A%0A    %7D
 %0A%7D%0A

fix bug initializing ToolBar