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