18340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne/*
28340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * Copyright (C) 2006 The Android Open Source Project
38340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne *
48340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * Licensed under the Apache License, Version 2.0 (the "License");
58340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * you may not use this file except in compliance with the License.
68340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * You may obtain a copy of the License at
78340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne *
88340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne *      http://www.apache.org/licenses/LICENSE-2.0
98340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne *
108340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * Unless required by applicable law or agreed to in writing, software
118340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * distributed under the License is distributed on an "AS IS" BASIS,
128340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * See the License for the specific language governing permissions and
148340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * limitations under the License.
158340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne */
168340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne
178340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunnepackage android.widget;
188340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne
198340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunneimport android.view.View;
208340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunneimport android.view.ViewGroup;
218340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne
228340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne/**
238340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * Additional methods that when implemented make an
248340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * {@link ExpandableListAdapter} take advantage of the {@link Adapter} view type
258340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * mechanism.
268e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne * <p>
278e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne * An {@link ExpandableListAdapter} declares it has one view type for its group items
288340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * and one view type for its child items. Although adapted for most {@link ExpandableListView}s,
298e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne * these values should be tuned for heterogeneous {@link ExpandableListView}s.
308e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne * </p>
318e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne * Lists that contain different types of group and/or child item views, should use an adapter that
328e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne * implements this interface. This way, the recycled views that will be provided to
338340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
348340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * and
358340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
368340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * will be of the appropriate group or child type, resulting in a more efficient reuse of the
378340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne * previously created views.
388340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne */
398340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunnepublic interface HeterogeneousExpandableList {
408340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    /**
418340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * Get the type of group View that will be created by
428340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
438340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * . for the specified group item.
448340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *
458340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @param groupPosition the position of the group for which the type should be returned.
468340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @return An integer representing the type of group View. Two group views should share the same
478340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         type if one can be converted to the other in
488340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
498340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         . Note: Integers must be in the range 0 to {@link #getGroupTypeCount} - 1.
508340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
518340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
528e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne     * @see #getGroupTypeCount()
538340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     */
548340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    int getGroupType(int groupPosition);
558340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne
568340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    /**
578340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * Get the type of child View that will be created by
588340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
598340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * for the specified child item.
608340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *
618340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @param groupPosition the position of the group that the child resides in
628340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @param childPosition the position of the child with respect to other children in the group
638340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @return An integer representing the type of child View. Two child views should share the same
648340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         type if one can be converted to the other in
658340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
668340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         Note: Integers must be in the range 0 to {@link #getChildTypeCount} - 1.
678340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *         {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
688340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
698e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne     * @see #getChildTypeCount()
708340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     */
718340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    int getChildType(int groupPosition, int childPosition);
728340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne
738340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    /**
748340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * <p>
758340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * Returns the number of types of group Views that will be created by
768340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
778340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * . Each type represents a set of views that can be converted in
788340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
798340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * . If the adapter always returns the same type of View for all group items, this method should
808340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * return 1.
818340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * </p>
828340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * This method will only be called when the adapter is set on the {@link AdapterView}.
838340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *
848340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @return The number of types of group Views that will be created by this adapter.
858e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne     * @see #getChildTypeCount()
868e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne     * @see #getGroupType(int)
878340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     */
888340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    int getGroupTypeCount();
898340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne
908340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    /**
918340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * <p>
928340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * Returns the number of types of child Views that will be created by
938340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
948340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * . Each type represents a set of views that can be converted in
958340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
968340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * , for any group. If the adapter always returns the same type of View for
978340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * all child items, this method should return 1.
988340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * </p>
998340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * This method will only be called when the adapter is set on the {@link AdapterView}.
1008340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     *
1018340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     * @return The total number of types of child Views that will be created by this adapter.
1028e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne     * @see #getGroupTypeCount()
1038e364ed01afd8b64e4e5464e46ba6fde301ac724Gilles Debunne     * @see #getChildType(int, int)
1048340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne     */
1058340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne    int getChildTypeCount();
1068340afe0f66663f032dd999e2d377564df0bb6d5Gilles Debunne}
107