Home | History | Annotate | Download | only in ui
      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      */
     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      */
     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      */
     49     boolean getShouldDisplayInList();
     50 
     51     /**
     52      * Returns the position (0 indexed) where this element expects to be inserted.
     53      * @return
     54      */
     55     int getPosition();
     56 
     57     void setAdapter(AnimatedAdapter adapter);
     58 
     59     void bindFragment(LoaderManager loaderManager, Bundle savedInstanceState);
     60 
     61     /**
     62      * Called when the view is being destroyed.
     63      */
     64     void cleanup();
     65 
     66     /**
     67      * Called when a regular conversation item was clicked.
     68      */
     69     void onConversationSelected();
     70 
     71     /**
     72      * Called whenever Cab Mode has been entered via long press or selecting a sender image.
     73      */
     74     void onCabModeEntered();
     75 
     76     /**
     77      * Called whenever Cab Mode has been exited.
     78      */
     79     void onCabModeExited();
     80 
     81     /** Returns whether this special view is enabled (= accepts user taps). */
     82     boolean acceptsUserTaps();
     83 
     84     /** Called when the conversation list's visibility changes */
     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      */
     90     void saveInstanceState(Bundle outState);
     91 }
     92