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;
19def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikasimport android.view.View;
20def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas
21ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.leanback.widget.BrowseFrameLayout;
22ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.leanback.widget.TitleHelper;
23ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.leanback.widget.TitleView;
24f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu
258cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stoutpublic class RowsActivity extends Activity
26f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu{
278cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout    private RowsFragment mRowsFragment;
288cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout
29f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu    /** Called when the activity is first created. */
30f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu    @Override
318cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout    public void onCreate(Bundle savedInstanceState) {
32f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu        super.onCreate(savedInstanceState);
33f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu        setContentView(R.layout.rows);
348cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout
358cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout        mRowsFragment = (RowsFragment) getFragmentManager().findFragmentById(
368cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout                R.id.main_rows_fragment);
378cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout
388cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout        setupTitleFragment();
39f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu    }
40f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu
418cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout    private void setupTitleFragment() {
42fa2e2acf79d791a90410025daad438968550d18cAlan Viverette        TitleView titleView = findViewById(R.id.title);
438cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout        titleView.setTitle("RowsFragment");
448cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout        titleView.setOnSearchClickedListener(new View.OnClickListener() {
458cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout            @Override
468cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout            public void onClick(View view) {
478cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout                Intent intent = new Intent(RowsActivity.this, SearchActivity.class);
488cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout                startActivity(intent);
498cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout            }
508cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout        });
518cef5c8d58f50d5baca1da44a7c19f623cbf98ecCraig Stout
52fa2e2acf79d791a90410025daad438968550d18cAlan Viverette        BrowseFrameLayout frameLayout = findViewById(R.id.rows_frame);
53b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu        TitleHelper titleHelper = new TitleHelper(frameLayout, titleView);
54b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu        frameLayout.setOnFocusSearchListener(titleHelper.getOnFocusSearchListener());
55b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu        mRowsFragment.setTitleHelper(titleHelper);
56f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu    }
57f4b2f81cf278d3f08d60feefee139b532db3ce01Dake Gu}
58