• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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 package com.android.mail.ui;
18 
19 import com.google.common.collect.Lists;
20 
21 import android.content.Context;
22 import android.view.LayoutInflater;
23 
24 import com.android.mail.providers.Account;
25 
26 import com.android.mail.R;
27 
28 import java.util.ArrayList;
29 
30 public class ConversationListHelper {
31     /**
32      * Creates a list of newly created special views.
33      */
makeConversationListSpecialViews( final Context context, final ControllableActivity activity, final Account account)34     public ArrayList<ConversationSpecialItemView> makeConversationListSpecialViews(
35             final Context context, final ControllableActivity activity, final Account account) {
36         // Note that these teasers have to be added in the order of importance because it's a stack,
37         // thus the last teaser added will appear on top.
38 
39         // Sync disabled teaser view
40         final ConversationSyncDisabledTipView conversationSyncDisabledTipView =
41                 new ConversationSyncDisabledTipView(context);
42         conversationSyncDisabledTipView.bindAccount(account, activity);
43 
44         // Message in outbox teaser view
45         final ConversationsInOutboxTipView conversationsInOutboxTipView =
46                 new ConversationsInOutboxTipView(context);
47         conversationsInOutboxTipView.bind(account, activity.getFolderSelector());
48 
49         // Conversation photo teaser view
50         final ConversationPhotoTeaserView conversationPhotoTeaser =
51                 new ConversationPhotoTeaserView(context);
52 
53         // Long press to select tip
54         final ConversationLongPressTipView conversationLongPressTipView =
55                 new ConversationLongPressTipView(context);
56 
57         final NestedFolderTeaserView nestedFolderTeaserView =
58                 (NestedFolderTeaserView) LayoutInflater.from(context)
59                         .inflate(R.layout.nested_folder_teaser_view, null);
60         nestedFolderTeaserView.bind(account, activity.getFolderSelector());
61 
62         // Order matters.  If a and b are added in order itemViews.add(a), itemViews.add(b),
63         // they will appear in conversation list as:
64         // b
65         // a
66         final ArrayList<ConversationSpecialItemView> itemViews = Lists.newArrayList();
67         itemViews.add(conversationPhotoTeaser);
68         itemViews.add(conversationLongPressTipView);
69         itemViews.add(conversationSyncDisabledTipView);
70         itemViews.add(conversationsInOutboxTipView);
71         itemViews.add(nestedFolderTeaserView);
72         return itemViews;
73     }
74 }
75