Home | History | Annotate | Download | only in old
      1 /*
      2  * Copyright (C) 2014 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.settings.dialog.old;
     18 
     19 import android.app.Activity;
     20 import android.app.Fragment;
     21 import android.graphics.Bitmap;
     22 import android.graphics.Color;
     23 import android.graphics.drawable.Drawable;
     24 import android.net.Uri;
     25 import android.os.Bundle;
     26 import android.view.LayoutInflater;
     27 import android.view.View;
     28 import android.view.ViewGroup;
     29 import android.widget.ImageView;
     30 import android.widget.RelativeLayout;
     31 import android.widget.TextView;
     32 
     33 /**
     34  * *************************
     35  *   DO NOT ADD LOGIC HERE!
     36  * *************************
     37  * This is a wrapper for {@link BaseContentFragment}. Place your logic in
     38  * there and call the function from here
     39  */
     40 public class ContentFragment extends Fragment implements LiteFragment {
     41 
     42     private final BaseContentFragment mBase = new BaseContentFragment(this);
     43 
     44     public static ContentFragment newInstance(String title) {
     45         return newInstance(title, null, null, 0, Color.TRANSPARENT);
     46     }
     47 
     48     public static ContentFragment newInstance(String title, String breadcrumb,
     49             String description) {
     50         return newInstance(title, breadcrumb, description, 0, Color.TRANSPARENT);
     51     }
     52 
     53     public static ContentFragment newInstance(String title, String breadcrumb, String description,
     54             int iconResourceId) {
     55         return newInstance(title, breadcrumb, description, iconResourceId, Color.TRANSPARENT);
     56     }
     57 
     58     public static ContentFragment newInstance(String title, String breadcrumb, String description,
     59             int iconResourceId, int iconBackgroundColor) {
     60         ContentFragment fragment = new ContentFragment();
     61         fragment.setArguments(
     62                 BaseContentFragment.buildArgs(title, breadcrumb, description, iconResourceId,
     63                         iconBackgroundColor));
     64         return fragment;
     65     }
     66 
     67     public static ContentFragment newInstance(String title, String breadcrumb, String description,
     68             Uri iconResourceUri) {
     69         return newInstance(title, breadcrumb, description, iconResourceUri, Color.TRANSPARENT);
     70     }
     71 
     72     public static ContentFragment newInstance(String title, String breadcrumb, String description,
     73             Uri iconResourceUri, int iconBackgroundColor) {
     74         ContentFragment fragment = new ContentFragment();
     75         fragment.setArguments(
     76                 BaseContentFragment.buildArgs(title, breadcrumb, description, iconResourceUri,
     77                 iconBackgroundColor));
     78         return fragment;
     79     }
     80 
     81     public static ContentFragment newInstance(String title, String breadcrumb, String description,
     82             Bitmap iconbitmap) {
     83         ContentFragment fragment = new ContentFragment();
     84         fragment.setArguments(BaseContentFragment.buildArgs(title, breadcrumb, description,
     85                 iconbitmap));
     86         return fragment;
     87     }
     88 
     89     @Override
     90     public void onCreate(Bundle savedInstanceState) {
     91         mBase.onCreate(savedInstanceState);
     92         super.onCreate(savedInstanceState);
     93     }
     94 
     95     @Override
     96     public void onSaveInstanceState(Bundle outState) {
     97         mBase.onSaveInstanceState(outState);
     98         super.onSaveInstanceState(outState);
     99     }
    100 
    101     @Override
    102     public void onAttach(Activity activity) {
    103         mBase.onAttach(activity);
    104         super.onAttach(activity);
    105     }
    106 
    107     @Override
    108     public void onDetach() {
    109         mBase.onDetach();
    110         super.onDetach();
    111     }
    112 
    113     @Override
    114     public View onCreateView(LayoutInflater inflater, ViewGroup container,
    115             Bundle savedInstanceState) {
    116         return mBase.onCreateView(inflater, container, savedInstanceState);
    117     }
    118 
    119     @Override
    120     public void onDestroyView() {
    121         mBase.onDestroyView();
    122         super.onDestroyView();
    123     }
    124 
    125     public ImageView getIcon() {
    126         return mBase.getIcon();
    127     }
    128 
    129     public TextView getTitle() {
    130         return mBase.getTitle();
    131     }
    132 
    133     public int getIconResourceId() {
    134         return mBase.getIconResourceId();
    135     }
    136 
    137     public Uri getIconResourceUri() {
    138         return mBase.getIconResourceUri();
    139     }
    140 
    141     public Bitmap getIconBitmap() {
    142         return mBase.getIconBitmap();
    143     }
    144 
    145     public RelativeLayout getRoot() {
    146         return mBase.getRoot();
    147     }
    148 
    149     public TextView getBreadCrumb() {
    150         return mBase.getBreadCrumb();
    151     }
    152 
    153     public TextView getDescription() {
    154         return mBase.getDescription();
    155     }
    156 
    157     public void setTextToExtra(int textViewResourceId, String extraLabel) {
    158         mBase.setTextToExtra(textViewResourceId, extraLabel);
    159     }
    160 
    161     public void setText(int textViewResourceId, String text) {
    162         mBase.setText(textViewResourceId, text);
    163     }
    164 
    165     public void setTitleText(String text) {
    166         mBase.setTitleText(text);
    167     }
    168 
    169     public void setBreadCrumbText(String text) {
    170         mBase.setBreadCrumbText(text);
    171     }
    172 
    173     public void setDescriptionText(String text) {
    174         mBase.setDescriptionText(text);
    175     }
    176 
    177     public void setIcon(int iconResourceId) {
    178         mBase.setIcon(iconResourceId);
    179     }
    180 
    181     public void setIcon(Uri iconUri) {
    182         mBase.setIcon(iconUri);
    183     }
    184 
    185     public void setIcon(Drawable iconDrawable) {
    186         mBase.setIcon(iconDrawable);
    187     }
    188 
    189     protected void setTextToExtra(View parent, int textViewResourceId, String extraLabel) {
    190         mBase.setTextToExtra(parent, textViewResourceId, extraLabel);
    191     }
    192 
    193     protected void setText(View parent, int textViewResourceId, String text) {
    194         mBase.setText(parent, textViewResourceId, text);
    195     }
    196 }
    197