OSDN Git Service

Playlists: sort ignoring case
[android-x86/packages-apps-Eleven.git] / src / org / lineageos / eleven / widgets / NoResultsContainer.java
1 /*
2 * Copyright (C) 2014 The CyanogenMod 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 package org.lineageos.eleven.widgets;
17
18 import android.content.Context;
19 import android.util.AttributeSet;
20 import android.view.View;
21 import android.widget.LinearLayout;
22 import android.widget.TextView;
23
24 import org.lineageos.eleven.R;
25
26 /**
27  * This class is the default empty state view for most listviews/fragments
28  * It allows the ability to set a main text, a main highlight text and a secondary text
29  * By default this container has some strings loaded, but other classes can call the apis to change
30  * the text
31  */
32 public class NoResultsContainer extends LinearLayout {
33     public NoResultsContainer(Context context, AttributeSet attrs) {
34         super(context, attrs);
35     }
36
37     /**
38      * This changes the Main text (top-most text) of the empty container
39      * @param resId String resource id
40      */
41     public void setMainText(final int resId) {
42         ((TextView)findViewById(R.id.no_results_main_text)).setText(resId);
43     }
44
45     public void setMainHighlightText(final String text) {
46         final TextView hightlightText = (TextView)findViewById(R.id.no_results_main_highlight_text);
47
48         if (text == null || text.isEmpty()) {
49             hightlightText.setVisibility(View.GONE);
50         } else {
51             hightlightText.setText(text);
52             hightlightText.setVisibility(View.VISIBLE);
53         }
54     }
55
56     public void setSecondaryText(final int resId) {
57         ((TextView)findViewById(R.id.no_results_secondary_text)).setText(resId);
58     }
59
60     public void setTextColor(int color) {
61         ((TextView)findViewById(R.id.no_results_main_text)).setTextColor(color);
62         ((TextView)findViewById(R.id.no_results_main_highlight_text)).setTextColor(color);
63         ((TextView)findViewById(R.id.no_results_secondary_text)).setTextColor(color);
64     }
65 }