com.skynet.dwhsu.cinema_browser.ui.MovieDetailActivity.java Source code

Java tutorial

Introduction

Here is the source code for com.skynet.dwhsu.cinema_browser.ui.MovieDetailActivity.java

Source

/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * 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.skynet.dwhsu.cinema_browser.ui;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.NavUtils;
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.view.View.OnClickListener;

import com.skynet.dwhsu.cinema_browser.R;

/**
 *   Activity for movie details for single pane view
 */

public class MovieDetailActivity extends AppCompatActivity implements OnClickListener {

    public static final String EXTRA_IMAGE = "extra_image";

    private static final String TAG = "MovieDetail";

    @TargetApi(VERSION_CODES.HONEYCOMB)
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.movie_detail_activity);
        final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        //mMovieId = getIntent().getStringExtra(Intent.EXTRA_TEXT);
        //Toast.makeText(getApplicationContext(),mMovieId,Toast.LENGTH_SHORT).show();
        if (savedInstanceState == null) {
            Fragment fragment = new MovieDetailFragment();
            Bundle args = new Bundle();
            args.putBoolean("hasData", true);
            args.putString("movieId", getIntent().getStringExtra(Intent.EXTRA_TITLE));
            args.putString("movieLink", getIntent().getStringExtra(Intent.EXTRA_TEXT));
            fragment.setArguments(args);
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction transaction = fm.beginTransaction();
            //transaction.replace(R.id.movieGridFragment, fragment);
            transaction.add(R.id.movieDetailFragment, fragment);
            transaction.commit();
        }
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

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

    /**
     * Set on the ImageView in the ViewPager children fragments, to enable/disable low profile mode
     * when the ImageView is touched.
     */
    @TargetApi(VERSION_CODES.HONEYCOMB)
    @Override
    public void onClick(View v) {

    }

}