/*
 * Copyright (C) 2015 Mateusz Widuch. All rights reserved.
 */

package eu.redray.trevie;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.Window;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Displays details of movie selected on the grid.
 */
public class MovieDetailsActivity extends AppCompatActivity {
    @Bind(R.id.toolbar)
    Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // Initialises progress bar
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setProgressBarIndeterminateVisibility(true);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_movie);
        ButterKnife.bind(this);

        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        // Retrieves data from intent to pass it to the fragment
        if (savedInstanceState == null) {
            // Create the detail fragment and add it to the activity
            // using a fragment transaction.
            Bundle arguments = new Bundle();
            arguments.putParcelable(Movie.EXTRA_DETAILS, getIntent().getParcelableExtra(Movie.EXTRA_DETAILS));

            MovieDetailsFragment fragment = new MovieDetailsFragment();
            fragment.setArguments(arguments);
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.movie_detail_container, fragment)
                    .commit();
        }
    }

    // Override up button behaviour so it goes back to previously created MainActivity
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                //Intent intent = NavUtils.getParentActivityIntent(this);
                //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                //NavUtils.navigateUpTo(this, intent);
                onBackPressed();
                return(true);
        }

        return(super.onOptionsItemSelected(item));
    }
}

@@ -881,16 +881,65 @@
 olbar);%0A
+        if (getSupportActionBar() != null) %7B%0A    
         
@@ -992,16 +992,26 @@
 d(true);
+%0A        %7D
 %0A%0A      
@@ -1179,31 +1179,16 @@
 activity
-%0A            //
  using a
@@ -1208,17 +1208,16 @@
 nsaction
-.
 %0A       
@@ -1660,17 +1660,18 @@
 %7D%0A%0A    /
-/
+**
  Overrid
@@ -1702,10 +1702,15 @@
  it 
-go
+navigat
 es b
@@ -1721,38 +1721,48 @@
 to p
+a
 re
-viously created MainActivity
+nt activity without recreating it. */
 %0A   
@@ -1906,238 +1906,8 @@
 me:%0A
-                //Intent intent = NavUtils.getParentActivityIntent(this);%0A                //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP %7C Intent.FLAG_ACTIVITY_SINGLE_TOP);%0A                //NavUtils.navigateUpTo(this, intent);%0A
     
@@ -1957,16 +1957,17 @@
   return
+ 
 (true);%0A
@@ -1991,16 +1991,17 @@
   return
+ 
 (super.o

Improve documentation of MovieDetailsActivity class