• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 Google Inc.
3  * Licensed to The Android Open Source Project.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package com.android.mail.ui;
19 
20 import android.content.Context;
21 import androidx.core.text.BidiFormatter;
22 import android.util.AttributeSet;
23 import android.widget.ImageView;
24 import android.widget.LinearLayout;
25 import android.widget.TextView;
26 
27 import com.android.mail.R;
28 import com.android.mail.providers.Folder;
29 import com.android.mail.utils.EmptyStateUtils;
30 
31 /**
32  * Empty view for {@link ConversationListFragment}.
33  */
34 public class ConversationListEmptyView extends LinearLayout {
35 
36     private ImageView mIcon;
37     private TextView mText;
38 
ConversationListEmptyView(Context context)39     public ConversationListEmptyView(Context context) {
40         this(context, null);
41     }
42 
ConversationListEmptyView(Context context, AttributeSet attrs)43     public ConversationListEmptyView(Context context, AttributeSet attrs) {
44         super(context, attrs);
45     }
46 
47     @Override
onFinishInflate()48     protected void onFinishInflate() {
49         super.onFinishInflate();
50 
51         mIcon = (ImageView) findViewById(R.id.empty_icon);
52         mText = (TextView) findViewById(R.id.empty_text);
53     }
54 
55     /**
56      * Initializes the empty view to use the proper icon and text
57      * based on the type of folder that will be visible.
58      */
setupEmptyText(final Folder folder, final String searchQuery, final BidiFormatter bidiFormatter, boolean shouldShowIcon)59     public void setupEmptyText(final Folder folder, final String searchQuery,
60             final BidiFormatter bidiFormatter, boolean shouldShowIcon) {
61         if (shouldShowIcon) {
62             EmptyStateUtils.bindEmptyFolderIcon(mIcon, folder);
63             mIcon.setVisibility(VISIBLE);
64         } else {
65             mIcon.setVisibility(GONE);
66         }
67 
68         EmptyStateUtils.bindEmptyFolderText(mText, folder, getResources(), searchQuery,
69                 bidiFormatter);
70     }
71 }
72