1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.support.v17.leanback.app;
17 
18 import android.app.Activity;
19 import android.app.FragmentTransaction;
20 
21 import android.content.Intent;
22 import android.os.Bundle;
23 import android.support.v17.leanback.tests.R;
24 
25 /**
26  * @hide from javadoc
27  */
28 public class BrowseFragmentTestActivity extends Activity {
29 
30     public static final String EXTRA_ADD_TO_BACKSTACK = "addToBackStack";
31     public static final String EXTRA_NUM_ROWS = "numRows";
32     public static final String EXTRA_REPEAT_PER_ROW = "repeatPerRow";
33     public static final String EXTRA_LOAD_DATA_DELAY = "loadDataDelay";
34     public static final String EXTRA_TEST_ENTRANCE_TRANSITION = "testEntranceTransition";
35 
36     @Override
onCreate(Bundle savedInstanceState)37     public void onCreate(Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39         Intent intent = getIntent();
40 
41         BrowseTestFragment.NUM_ROWS = intent.getIntExtra(EXTRA_NUM_ROWS,
42                 BrowseTestFragment.DEFAULT_NUM_ROWS);
43         BrowseTestFragment.REPEAT_PER_ROW = intent.getIntExtra(EXTRA_REPEAT_PER_ROW,
44                 BrowseTestFragment.DEFAULT_REPEAT_PER_ROW);
45         BrowseTestFragment.LOAD_DATA_DELAY = intent.getLongExtra(EXTRA_LOAD_DATA_DELAY,
46                 BrowseTestFragment.DEFAULT_LOAD_DATA_DELAY);
47         BrowseTestFragment.TEST_ENTRANCE_TRANSITION = intent.getBooleanExtra(
48                 EXTRA_TEST_ENTRANCE_TRANSITION,
49                 BrowseTestFragment.DEFAULT_TEST_ENTRANCE_TRANSITION);
50         setContentView(R.layout.browse);
51         FragmentTransaction ft = getFragmentManager().beginTransaction();
52         ft.replace(R.id.main_frame, new BrowseTestFragment());
53         if (intent.getBooleanExtra(EXTRA_ADD_TO_BACKSTACK, false)) {
54             ft.addToBackStack(null);
55         }
56         ft.commit();
57     }
58 
getBrowseTestFragment()59     public BrowseTestFragment getBrowseTestFragment() {
60         return (BrowseTestFragment) getFragmentManager().findFragmentById(R.id.main_frame);
61     }
62 }
63