• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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;
18 
19 import android.annotation.DrawableRes;
20 import android.annotation.Nullable;
21 import android.annotation.StringRes;
22 import android.app.Fragment;
23 import android.graphics.drawable.Drawable;
24 import android.os.Bundle;
25 import android.text.TextUtils;
26 import android.view.LayoutInflater;
27 import android.view.View;
28 import android.view.ViewGroup;
29 import android.widget.ImageView;
30 import android.widget.ProgressBar;
31 import android.widget.TextView;
32 
33 import com.android.tv.settings.R;
34 
35 public class ProgressDialogFragment extends Fragment {
36 
37     private ImageView mIconView;
38     private TextView mTitleView;
39     private TextView mTitleEndView;
40     private TextView mSummaryView;
41     private ProgressBar mProgressBar;
42 
43     @Override
onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState)44     public @Nullable View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
45             Bundle savedInstanceState) {
46         final ViewGroup view =
47                 (ViewGroup) inflater.inflate(R.layout.progress_fragment, container, false);
48 
49         mIconView = (ImageView) view.findViewById(android.R.id.icon);
50         mTitleView = (TextView) view.findViewById(android.R.id.title);
51         mTitleEndView = (TextView) view.findViewById(R.id.title_end);
52         mSummaryView = (TextView) view.findViewById(android.R.id.summary);
53         mProgressBar = (ProgressBar) view.findViewById(android.R.id.progress);
54 
55         return view;
56     }
57 
setIcon(@rawableRes int resId)58     public void setIcon(@DrawableRes int resId) {
59         mIconView.setImageResource(resId);
60         mIconView.setVisibility(View.VISIBLE);
61     }
62 
setIcon(@ullable Drawable icon)63     public void setIcon(@Nullable Drawable icon) {
64         mIconView.setImageDrawable(icon);
65         mIconView.setVisibility(icon == null ? View.GONE : View.VISIBLE);
66     }
67 
setTitle(@tringRes int resId)68     public void setTitle(@StringRes int resId) {
69         mTitleView.setText(resId);
70     }
71 
setTitle(CharSequence title)72     public void setTitle(CharSequence title) {
73         mTitleView.setText(title);
74     }
75 
setTitleEnd(@tringRes int resId)76     public void setTitleEnd(@StringRes int resId) {
77         mTitleEndView.setText(resId);
78     }
79 
setTitleEnd(CharSequence title)80     public void setTitleEnd(CharSequence title) {
81         mTitleEndView.setText(title);
82         mTitleEndView.setVisibility(TextUtils.isEmpty(title) ? View.GONE : View.VISIBLE);
83     }
84 
setSummary(@tringRes int resId)85     public void setSummary(@StringRes int resId) {
86         mSummaryView.setText(resId);
87     }
88 
setSummary(CharSequence title)89     public void setSummary(CharSequence title) {
90         mSummaryView.setText(title);
91     }
92 
setIndeterminte(boolean indeterminte)93     public void setIndeterminte(boolean indeterminte) {
94         mProgressBar.setIndeterminate(indeterminte);
95     }
96 
setProgress(int progress)97     public void setProgress(int progress) {
98         mProgressBar.setProgress(progress);
99     }
100 
setProgressMax(int max)101     public void setProgressMax(int max) {
102         mProgressBar.setMax(max);
103     }
104 }
105