1f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu/* 2f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * Copyright (C) 2014 The Android Open Source Project 3f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * 4f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * in compliance with the License. You may obtain a copy of the License at 6f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * 7f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * http://www.apache.org/licenses/LICENSE-2.0 8f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * 9f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * Unless required by applicable law or agreed to in writing, software distributed under the License 10f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * or implied. See the License for the specific language governing permissions and limitations under 12f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu * the License. 13f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu */ 14f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gupackage com.example.android.leanback; 15f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu 16f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Guimport android.app.Activity; 178cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stoutimport android.content.Intent; 18f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Guimport android.os.Bundle; 198cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stoutimport android.support.v17.leanback.widget.BrowseFrameLayout; 208cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stoutimport android.support.v17.leanback.widget.TitleHelper; 218cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stoutimport android.support.v17.leanback.widget.TitleView; 22f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Guimport android.view.View; 23f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu 248cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stoutpublic class RowsActivity extends Activity 25f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu{ 268cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout private RowsFragment mRowsFragment; 278cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout 28f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu /** Called when the activity is first created. */ 29f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu @Override 308cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout public void onCreate(Bundle savedInstanceState) { 31f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu super.onCreate(savedInstanceState); 32f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu setContentView(R.layout.rows); 338cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout 348cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout mRowsFragment = (RowsFragment) getFragmentManager().findFragmentById( 358cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout R.id.main_rows_fragment); 368cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout 378cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout setupTitleFragment(); 38f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu } 39f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu 408cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout private void setupTitleFragment() { 41fa2e2acf79d791a90410025daad438968550d18cAlan Viverette TitleView titleView = findViewById(R.id.title); 428cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout titleView.setTitle("RowsFragment"); 438cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout titleView.setOnSearchClickedListener(new View.OnClickListener() { 448cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout @Override 458cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout public void onClick(View view) { 468cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout Intent intent = new Intent(RowsActivity.this, SearchActivity.class); 478cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout startActivity(intent); 488cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout } 498cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout }); 508cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout 51fa2e2acf79d791a90410025daad438968550d18cAlan Viverette BrowseFrameLayout frameLayout = findViewById(R.id.rows_frame); 52b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu TitleHelper titleHelper = new TitleHelper(frameLayout, titleView); 53b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu frameLayout.setOnFocusSearchListener(titleHelper.getOnFocusSearchListener()); 54b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu mRowsFragment.setTitleHelper(titleHelper); 55f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu } 56f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu} 57