• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 
17 package com.android.car.settings.home;
18 
19 import android.annotation.DrawableRes;
20 import android.annotation.StringRes;
21 import android.content.Context;
22 import android.view.View;
23 
24 import com.android.car.list.SimpleIconLineItem;
25 import com.android.car.settings.common.BaseFragment;
26 
27 /**
28  * This class extends {@link SimpleIconLineItem} and adds the onClick behavior to
29  * trigger the fragmentController to launch a new fragment when clicked.
30  * The fragment passed in is what will be launched.
31  */
32 public class SimpleIconTransitionLineItem extends SimpleIconLineItem {
33 
34     private BaseFragment.FragmentController mFragmentController;
35     private BaseFragment mFragment;
36 
SimpleIconTransitionLineItem( @tringRes int title, @DrawableRes int iconRes, Context context, CharSequence desc, BaseFragment fragment, BaseFragment.FragmentController fragmentController)37     public SimpleIconTransitionLineItem(
38             @StringRes int title,
39             @DrawableRes int iconRes,
40             Context context,
41             CharSequence desc,
42             BaseFragment fragment,
43             BaseFragment.FragmentController fragmentController) {
44         super(title, iconRes, context, desc);
45         mFragment = fragment;
46         mFragmentController = fragmentController;
47     }
48 
onClick(View view)49     public void onClick(View view) {
50         mFragmentController.launchFragment(mFragment);
51     }
52 
53 }
54