• 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 android.app.LoaderManager;
20 import android.os.Bundle;
21 import android.widget.Adapter;
22 
23 import com.android.mail.browse.ConversationCursor;
24 import com.android.mail.providers.Folder;
25 
26 /**
27  * An interface for a view that can be inserted into an {@link AnimatedAdapter} at an arbitrary
28  * point. The methods described here control whether the view gets displayed, and what it displays.
29  */
30 public interface ConversationSpecialItemView {
31     /**
32      * Called when there as an update to the information being displayed.
33      *
34      * @param cursor The {@link ConversationCursor}. May be <code>null</code>
35      */
onUpdate(Folder folder, ConversationCursor cursor)36     void onUpdate(Folder folder, ConversationCursor cursor);
37 
38     /**
39      * Called before returning this view from
40      * {@link Adapter#getView(int, android.view.View, android.view.ViewGroup)}
41      */
onGetView()42     void onGetView();
43 
44     /**
45      * Returns whether this view is to be displayed in the list or not. A view can be added freely
46      * and it might decide to disable itself by returning false here.
47      * @return true if this view should be displayed, false otherwise.
48      */
getShouldDisplayInList()49     boolean getShouldDisplayInList();
50 
51     /**
52      * Returns the position (0 indexed) where this element expects to be inserted.
53      * @return
54      */
getPosition()55     int getPosition();
56 
setAdapter(AnimatedAdapter adapter)57     void setAdapter(AnimatedAdapter adapter);
58 
bindFragment(LoaderManager loaderManager, Bundle savedInstanceState)59     void bindFragment(LoaderManager loaderManager, Bundle savedInstanceState);
60 
61     /**
62      * Called when the view is being destroyed.
63      */
cleanup()64     void cleanup();
65 
66     /**
67      * Called when a regular conversation item was clicked.
68      */
onConversationSelected()69     void onConversationSelected();
70 
71     /**
72      * Called whenever Cab Mode has been entered via long press or selecting a sender image.
73      */
onCabModeEntered()74     void onCabModeEntered();
75 
76     /**
77      * Called whenever Cab Mode has been exited.
78      */
onCabModeExited()79     void onCabModeExited();
80 
81     /** Returns whether this special view is enabled (= accepts user taps). */
acceptsUserTaps()82     boolean acceptsUserTaps();
83 
84     /** Called when the conversation list's visibility changes */
onConversationListVisibilityChanged(boolean visible)85     void onConversationListVisibilityChanged(boolean visible);
86 
87     /**
88      * Saves any state for the view to the fragment so it will be restored on configuration change
89      */
saveInstanceState(Bundle outState)90     void saveInstanceState(Bundle outState);
91 
92     /**
93      * <p>
94      * Commits any leave-behind items for this special view.
95      * </p>
96      * <p>
97      * This should generally be used for committing any destructive actions that the leave-behind
98      * allows you to undo, and it should cause the leave-behind to disappear.
99      * </p>
100      *
101      * @return <code>true</code> if there was a leave-behind that has been committed,
102      *         <code>false</code> otherwise
103      */
commitLeaveBehindItem()104     boolean commitLeaveBehindItem();
105 }
106