1 /* This file is auto-generated from DetailsActivity.java.  DO NOT MODIFY. */
2 
3 /*
4  * Copyright (C) 2014 The Android Open Source Project
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7  * in compliance with the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software distributed under the License
12  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13  * or implied. See the License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 package com.example.android.leanback;
17 
18 import android.support.v4.app.FragmentActivity;
19 import android.os.Bundle;
20 
21 public class DetailsSupportActivity extends FragmentActivity
22 {
23     public static final String EXTRA_ITEM = "item";
24     public static final String SHARED_ELEMENT_NAME = "hero";
25 
useLegacyFragment()26     private boolean useLegacyFragment() {
27         return (DetailsPresenterSelectionActivity.USE_LEGACY_PRESENTER
28                 && !(this instanceof SearchDetailsSupportActivity));
29     }
30 
31     /** Called when the activity is first created. */
32     @Override
onCreate(Bundle savedInstanceState)33     public void onCreate(Bundle savedInstanceState)
34     {
35         super.onCreate(savedInstanceState);
36         setContentView(useLegacyFragment() ? R.layout.legacy_details_support : R.layout.details_support);
37         if (savedInstanceState == null) {
38             // Only pass object to fragment when activity is first time created,
39             // later object is modified and persisted with fragment state.
40             if (useLegacyFragment()) {
41                 ((DetailsSupportFragment)getSupportFragmentManager().findFragmentById(R.id.details_fragment))
42                     .setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
43             } else {
44                 ((NewDetailsSupportFragment)getSupportFragmentManager().findFragmentById(R.id.details_fragment))
45                     .setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
46             }
47         }
48     }
49 
50     @Override
onAttachedToWindow()51     public void onAttachedToWindow() {
52         super.onAttachedToWindow();
53         BackgroundHelper.attach(this);
54     }
55 
56     @Override
onStop()57     public void onStop() {
58         BackgroundHelper.release(this);
59         super.onStop();
60     }
61 }
62