• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // CHECKSTYLE:OFF Generated code
2 /* This file is auto-generated from SingleFragmentTestActivity.java.  DO NOT MODIFY. */
3 
4 /*
5  * Copyright (C) 2016 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package android.support.v17.leanback.app;
20 
21 import android.support.v4.app.FragmentActivity;
22 import android.support.v4.app.Fragment;
23 import android.support.v4.app.FragmentTransaction;
24 import android.content.Intent;
25 import android.os.Bundle;
26 import android.support.v17.leanback.test.R;
27 import android.util.Log;
28 
29 public class SingleSupportFragmentTestActivity extends FragmentActivity {
30 
31     /**
32      * Fragment that will be added to activity
33      */
34     public static final String EXTRA_FRAGMENT_NAME = "fragmentName";
35 
36     public static final String EXTRA_ACTIVITY_LAYOUT = "activityLayout";
37 
38     public static final String EXTRA_UI_VISIBILITY = "uiVisibility";
39     private static final String TAG = "TestActivity";
40 
41     @Override
onCreate(Bundle savedInstanceState)42     public void onCreate(Bundle savedInstanceState) {
43         super.onCreate(savedInstanceState);
44         Log.d(TAG, "onCreate " + this);
45         Intent intent = getIntent();
46 
47         final int uiOptions = intent.getIntExtra(EXTRA_UI_VISIBILITY, 0);
48         if (uiOptions != 0) {
49             getWindow().getDecorView().setSystemUiVisibility(uiOptions);
50         }
51 
52         setContentView(intent.getIntExtra(EXTRA_ACTIVITY_LAYOUT, R.layout.single_fragment));
53         if (savedInstanceState == null && findViewById(R.id.main_frame) != null) {
54             try {
55                 Fragment fragment = (Fragment) Class.forName(
56                         intent.getStringExtra(EXTRA_FRAGMENT_NAME)).newInstance();
57                 FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
58                 ft.replace(R.id.main_frame, fragment);
59                 ft.commit();
60             } catch (Exception ex) {
61                 ex.printStackTrace();
62                 finish();
63             }
64         }
65     }
66 
getTestFragment()67     public Fragment getTestFragment() {
68         return getSupportFragmentManager().findFragmentById(R.id.main_frame);
69     }
70 }
71