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 androidx.leanback.app; 17 18 import android.content.Intent; 19 import android.os.Bundle; 20 21 import androidx.fragment.app.FragmentActivity; 22 import androidx.fragment.app.FragmentTransaction; 23 import androidx.leanback.test.R; 24 25 public class BrowseSupportFragmentTestActivity extends FragmentActivity { 26 27 public static final String EXTRA_ADD_TO_BACKSTACK = "addToBackStack"; 28 public static final String EXTRA_NUM_ROWS = "numRows"; 29 public static final String EXTRA_REPEAT_PER_ROW = "repeatPerRow"; 30 public static final String EXTRA_LOAD_DATA_DELAY = "loadDataDelay"; 31 public static final String EXTRA_TEST_ENTRANCE_TRANSITION = "testEntranceTransition"; 32 public static final String EXTRA_SET_ADAPTER_AFTER_DATA_LOAD = "set_adapter_after_data_load"; 33 public static final String EXTRA_HEADERS_STATE = "headers_state"; 34 35 @Override onCreate(Bundle savedInstanceState)36 public void onCreate(Bundle savedInstanceState) { 37 super.onCreate(savedInstanceState); 38 Intent intent = getIntent(); 39 40 setContentView(R.layout.browse); 41 if (savedInstanceState == null) { 42 Bundle arguments = new Bundle(); 43 arguments.putAll(intent.getExtras()); 44 BrowseTestSupportFragment fragment = new BrowseTestSupportFragment(); 45 fragment.setArguments(arguments); 46 FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); 47 ft.replace(R.id.main_frame, fragment); 48 if (intent.getBooleanExtra(EXTRA_ADD_TO_BACKSTACK, false)) { 49 ft.addToBackStack(null); 50 } 51 ft.commit(); 52 } 53 } 54 getBrowseTestSupportFragment()55 public BrowseTestSupportFragment getBrowseTestSupportFragment() { 56 return (BrowseTestSupportFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame); 57 } 58 } 59