2 * Copyright (C) 2014 The CyanogenMod Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.lineageos.eleven.widgets;
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;
24 import org.lineageos.eleven.R;
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
32 public class NoResultsContainer extends LinearLayout {
33 public NoResultsContainer(Context context, AttributeSet attrs) {
34 super(context, attrs);
38 * This changes the Main text (top-most text) of the empty container
39 * @param resId String resource id
41 public void setMainText(final int resId) {
42 ((TextView)findViewById(R.id.no_results_main_text)).setText(resId);
45 public void setMainHighlightText(final String text) {
46 final TextView hightlightText = (TextView)findViewById(R.id.no_results_main_highlight_text);
48 if (text == null || text.isEmpty()) {
49 hightlightText.setVisibility(View.GONE);
51 hightlightText.setText(text);
52 hightlightText.setVisibility(View.VISIBLE);
56 public void setSecondaryText(final int resId) {
57 ((TextView)findViewById(R.id.no_results_secondary_text)).setText(resId);
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);