FolderDisplayer.java revision 2c6cf4c5e3d04907f2f030dedf983d77de730a4f
1/* 2 * Copyright (C) 2012 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 18package com.android.mail.ui; 19 20import com.android.mail.utils.LogTag; 21import com.google.common.collect.Sets; 22 23import android.content.Context; 24import android.net.Uri; 25 26import com.android.mail.R; 27import com.android.mail.providers.Conversation; 28import com.android.mail.providers.Folder; 29import com.android.mail.providers.UIProvider.FolderType; 30 31import java.util.SortedSet; 32 33/** 34 * Used to generate folder display information given a raw folders string. 35 * (The raw folders string can be obtained from {@link Conversation#rawFolders}.) 36 * 37 */ 38public class FolderDisplayer { 39 public static final String LOG_TAG = LogTag.getLogTag(); 40 protected Context mContext; 41 protected final SortedSet<Folder> mFoldersSortedSet = Sets.newTreeSet(); 42 43 protected final int mDefaultBgColor; 44 protected final int mDefaultFgColor; 45 46 public FolderDisplayer(Context context) { 47 mContext = context; 48 49 mDefaultFgColor = context.getResources().getColor(R.color.default_folder_foreground_color); 50 mDefaultBgColor = context.getResources().getColor(R.color.default_folder_background_color); 51 } 52 53 /** 54 * Configure the FolderDisplayer object by parsing the rawFolders string. 55 * 56 * @param conv {@link Conversation} containing the folders to display. 57 * @param ignoreFolderUri (optional) folder to omit from the displayed set 58 * @param ignoreFolderType -1, or the {@link FolderType} to omit from the displayed set 59 */ 60 public void loadConversationFolders(Conversation conv, final Uri ignoreFolderUri, 61 final int ignoreFolderType) { 62 mFoldersSortedSet.clear(); 63 mFoldersSortedSet.addAll(conv.getRawFoldersForDisplay(ignoreFolderUri, ignoreFolderType)); 64 } 65 66 /** 67 * Reset this FolderDisplayer so that it can be reused. 68 */ 69 public void reset() { 70 mFoldersSortedSet.clear(); 71 } 72} 73