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 18 package com.android.mail.ui; 19 20 import android.app.LoaderManager.LoaderCallbacks; 21 import android.database.DataSetObserver; 22 import android.os.Bundle; 23 import android.os.Parcelable; 24 25 import com.android.mail.browse.ConversationCursor; 26 import com.android.mail.providers.Conversation; 27 28 /** 29 * A controller interface that is to receive user initiated events and handle them. 30 */ 31 public interface ConversationListCallbacks { 32 /** 33 * Show the conversation provided here. If the conversation is null, this is a request to pop 34 * <em>out</em> of conversation view mode and head back to conversation list mode, or whatever 35 * should best show in its place. 36 * @param conversation conversation to display, possibly null. 37 * @param inLoaderCallbacks whether we are in the scope of a {@link LoaderCallbacks} method 38 * (when fragment transactions are disallowed) 39 */ 40 void onConversationSelected(Conversation conversation, boolean inLoaderCallbacks); 41 42 /** 43 * Called whenever CAB mode has been entered via long press or selecting a sender image. 44 */ 45 void onCabModeEntered(); 46 47 /** 48 * Called whenever CAB mode has been exited. 49 */ 50 void onCabModeExited(); 51 52 ConversationCursor getConversationListCursor(); 53 54 Conversation getCurrentConversation(); 55 void setCurrentConversation(Conversation c); 56 57 /** 58 * Returns whether the initial conversation has begun but not finished loading. If this returns 59 * true, you can register to be told when the load in progress finishes 60 * ({@link #registerConversationLoadedObserver(DataSetObserver)}). 61 * <p> 62 * This flag only applies to the first conversation in a set (e.g. when using ViewPager). 63 * 64 * @return true if the initial conversation has begun but not finished loading 65 */ 66 boolean isInitialConversationLoading(); 67 void registerConversationLoadedObserver(DataSetObserver observer); 68 void unregisterConversationLoadedObserver(DataSetObserver observer); 69 /** 70 * Coordinates actions that might occur in response to a conversation that has finished loading 71 * and is now user-visible. 72 */ 73 void onConversationSeen(); 74 75 void registerConversationListObserver(DataSetObserver observer); 76 void unregisterConversationListObserver(DataSetObserver observer); 77 78 /** 79 * Commit any destructive action leave behind items so that it is no longer 80 * possible to undo them. 81 */ 82 void commitDestructiveActions(boolean animate); 83 84 /** 85 * Detect if there are any animations occurring in the conversation list. 86 */ 87 boolean isAnimating(); 88 89 /** 90 * Tell the controller that the conversation view has entered detached mode. 91 */ 92 void setDetachedMode(); 93 94 String CONVERSATION_LIST_SCROLL_POSITION_INDEX = "index"; 95 String CONVERSATION_LIST_SCROLL_POSITION_OFFSET = "offset"; 96 97 /** 98 * Gets the last save scroll position of the conversation list for the specified Folder. 99 * 100 * @return A {@link Bundle} containing two ints, 101 * {@link #CONVERSATION_LIST_SCROLL_POSITION_INDEX} and 102 * {@link #CONVERSATION_LIST_SCROLL_POSITION_OFFSET}, or <code>null</code> 103 */ 104 Parcelable getConversationListScrollPosition(String folderUri); 105 106 /** 107 * Sets the last save scroll position of the conversation list for the specified Folder for 108 * restoration on returning to this list. 109 * 110 * @param savedPosition A {@link Bundle} containing two ints, 111 * {@link #CONVERSATION_LIST_SCROLL_POSITION_INDEX} and 112 * {@link #CONVERSATION_LIST_SCROLL_POSITION_OFFSET} 113 */ 114 void setConversationListScrollPosition(String folderUri, Parcelable savedPosition); 115 } 116