1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
12 * the License.
13 */
14package com.example.android.leanback;
15
16import android.app.Activity;
17import android.content.Intent;
18import android.os.Bundle;
19import android.view.View;
20
21import androidx.leanback.widget.BrowseFrameLayout;
22import androidx.leanback.widget.TitleHelper;
23import androidx.leanback.widget.TitleView;
24
25public class RowsActivity extends Activity
26{
27    private RowsFragment mRowsFragment;
28
29    /** Called when the activity is first created. */
30    @Override
31    public void onCreate(Bundle savedInstanceState) {
32        super.onCreate(savedInstanceState);
33        setContentView(R.layout.rows);
34
35        mRowsFragment = (RowsFragment) getFragmentManager().findFragmentById(
36                R.id.main_rows_fragment);
37
38        setupTitleFragment();
39    }
40
41    private void setupTitleFragment() {
42        TitleView titleView = findViewById(R.id.title);
43        titleView.setTitle("RowsFragment");
44        titleView.setOnSearchClickedListener(new View.OnClickListener() {
45            @Override
46            public void onClick(View view) {
47                Intent intent = new Intent(RowsActivity.this, SearchActivity.class);
48                startActivity(intent);
49            }
50        });
51
52        BrowseFrameLayout frameLayout = findViewById(R.id.rows_frame);
53        TitleHelper titleHelper = new TitleHelper(frameLayout, titleView);
54        frameLayout.setOnFocusSearchListener(titleHelper.getOnFocusSearchListener());
55        mRowsFragment.setTitleHelper(titleHelper);
56    }
57}
58