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 public class DetailsSupportActivity extends FragmentActivity
24 {
25     public static final String EXTRA_ITEM = "item";
26     public static final String SHARED_ELEMENT_NAME = "hero";
27 
useLegacyFragment()28     private boolean useLegacyFragment() {
29         return (DetailsPresenterSelectionActivity.USE_LEGACY_PRESENTER
30                 && !(this instanceof SearchDetailsSupportActivity));
31     }
32 
hasBackgroundVideo()33     protected boolean hasBackgroundVideo() {
34         return false;
35     }
36 
37     /** Called when the activity is first created. */
38     @Override
onCreate(Bundle savedInstanceState)39     public void onCreate(Bundle savedInstanceState)
40     {
41         super.onCreate(savedInstanceState);
42         getSupportFragmentManager().enableDebugLogging(true);
43         setContentView(R.layout.details_activity);
44         if (savedInstanceState == null) {
45             if (useLegacyFragment()) {
46                 DetailsSupportFragment fragment = new DetailsSupportFragment();
47                 fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
48                 getSupportFragmentManager().beginTransaction()
49                         .replace(R.id.details_fragment, fragment)
50                         .commit();
51             } else {
52                 NewDetailsSupportFragment fragment = new NewDetailsSupportFragment();
53                 fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
54                 fragment.setBackgroundVideo(hasBackgroundVideo());
55                 getSupportFragmentManager().beginTransaction()
56                         .replace(R.id.details_fragment, fragment)
57                         .commit();
58             }
59         } else {
60             if (useLegacyFragment()) {
61                 DetailsSupportFragment fragment = (DetailsSupportFragment) getSupportFragmentManager()
62                         .findFragmentById(R.id.details_fragment);
63                 fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
64             } else {
65                 NewDetailsSupportFragment fragment = (NewDetailsSupportFragment) getSupportFragmentManager()
66                         .findFragmentById(R.id.details_fragment);
67                 fragment.setItem((PhotoItem) getIntent().getParcelableExtra(EXTRA_ITEM));
68             }
69         }
70     }
71 }
72