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.mail.drawer; 18 19 import android.view.View; 20 import android.view.ViewGroup; 21 import android.widget.TextView; 22 23 import com.android.mail.R; 24 import com.android.mail.ui.ControllableActivity; 25 import com.android.mail.utils.FolderUri; 26 27 class HeaderDrawerItem extends DrawerItem { 28 private final int mResource; 29 HeaderDrawerItem(ControllableActivity activity, int resource)30 HeaderDrawerItem(ControllableActivity activity, int resource) { 31 super(activity, null, NONFOLDER_ITEM, null); 32 mResource = resource; 33 } 34 35 @Override toString()36 public String toString() { 37 return "[DrawerItem VIEW_HEADER, mResource=" + mResource + "]"; 38 } 39 40 /** 41 * Returns a text divider between divisions. 42 * 43 * @param convertView a previous view, perhaps null 44 * @param parent the parent of this view 45 * @return a text header at the given position. 46 */ 47 @Override getView(View convertView, ViewGroup parent)48 public View getView(View convertView, ViewGroup parent) { 49 final View headerView; 50 if (convertView != null) { 51 headerView = convertView; 52 } else { 53 headerView = mInflater.inflate(R.layout.folder_list_header, parent, false); 54 } 55 final TextView textView = (TextView) headerView.findViewById(R.id.header_text); 56 textView.setText(mResource); 57 return headerView; 58 } 59 60 @Override isHighlighted(FolderUri currentFolder, int currentType)61 public boolean isHighlighted(FolderUri currentFolder, int currentType) { 62 return false; 63 } 64 65 @Override isItemEnabled()66 public boolean isItemEnabled() { 67 return false; 68 } 69 70 @Override getType()71 public @DrawerItemType int getType() { 72 return VIEW_HEADER; 73 } 74 } 75