1 /*
2  * Copyright (C) 2020 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.tv.twopanelsettings.slices;
18 
19 
20 import android.app.Fragment;
21 import android.graphics.drawable.Icon;
22 import android.os.Bundle;
23 import android.view.LayoutInflater;
24 import android.view.View;
25 import android.view.ViewGroup;
26 import android.widget.ImageView;
27 import android.widget.TextView;
28 
29 import com.android.tv.twopanelsettings.R;
30 
31 /**
32  * Fragment to display informational image and description text for slice.
33  */
34 public class InfoFragment extends Fragment {
35 
36     @Override
onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)37     public View onCreateView(
38             LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
39         View view = inflater.inflate(R.layout.info_fragment, container, false);
40         Icon image = getArguments().getParcelable(SlicesConstants.EXTRA_PREFERENCE_INFO_IMAGE);
41         String text = getArguments().getString(SlicesConstants.EXTRA_PREFERENCE_INFO_TEXT);
42         if (image != null) {
43             ((ImageView) view.findViewById(R.id.info_image))
44                     .setImageDrawable(image.loadDrawable(getContext()));
45         }
46         if (text != null) {
47             ((TextView) view.findViewById(R.id.info_text)).setText(text);
48         }
49         return view;
50     }
51 }
52