mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 20:27:58 +03:00
ExpandableListView: borrow from AOSP master (commit 272d3ffb52e10ee821eaf58fa398376c45b16b06)
This commit is contained in:
parent
2e9099baed
commit
582307f74c
8 changed files with 3063 additions and 10 deletions
|
@ -2,6 +2,8 @@ package android.view;
|
||||||
|
|
||||||
public class SoundEffectConstants {
|
public class SoundEffectConstants {
|
||||||
|
|
||||||
|
public static final int CLICK = 0;
|
||||||
|
|
||||||
// the typo is part of the API
|
// the typo is part of the API
|
||||||
public static int getContantForFocusDirection(int direction) {
|
public static int getContantForFocusDirection(int direction) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
137
src/api-impl/android/widget/BaseExpandableListAdapter.java
Normal file
137
src/api-impl/android/widget/BaseExpandableListAdapter.java
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.widget;
|
||||||
|
|
||||||
|
import android.database.DataSetObservable;
|
||||||
|
import android.database.DataSetObserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for a {@link ExpandableListAdapter} used to provide data and Views
|
||||||
|
* from some data to an expandable list view.
|
||||||
|
* <p>
|
||||||
|
* Adapters inheriting this class should verify that the base implementations of
|
||||||
|
* {@link #getCombinedChildId(long, long)} and {@link #getCombinedGroupId(long)}
|
||||||
|
* are correct in generating unique IDs from the group/children IDs.
|
||||||
|
* <p>
|
||||||
|
* @see SimpleExpandableListAdapter
|
||||||
|
* @see SimpleCursorTreeAdapter
|
||||||
|
*/
|
||||||
|
public abstract class BaseExpandableListAdapter implements ExpandableListAdapter,
|
||||||
|
HeterogeneousExpandableList {
|
||||||
|
private final DataSetObservable mDataSetObservable = new DataSetObservable();
|
||||||
|
|
||||||
|
public void registerDataSetObserver(DataSetObserver observer) {
|
||||||
|
mDataSetObservable.registerObserver(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||||
|
mDataSetObservable.unregisterObserver(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DataSetObservable#notifyInvalidated()
|
||||||
|
*/
|
||||||
|
public void notifyDataSetInvalidated() {
|
||||||
|
mDataSetObservable.notifyInvalidated();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DataSetObservable#notifyChanged()
|
||||||
|
*/
|
||||||
|
public void notifyDataSetChanged() {
|
||||||
|
mDataSetObservable.notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean areAllItemsEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGroupCollapsed(int groupPosition) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGroupExpanded(int groupPosition) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override this method if you foresee a clash in IDs based on this scheme:
|
||||||
|
* <p>
|
||||||
|
* Base implementation returns a long:
|
||||||
|
* <li> bit 0: Whether this ID points to a child (unset) or group (set), so for this method
|
||||||
|
* this bit will be 1.
|
||||||
|
* <li> bit 1-31: Lower 31 bits of the groupId
|
||||||
|
* <li> bit 32-63: Lower 32 bits of the childId.
|
||||||
|
* <p>
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public long getCombinedChildId(long groupId, long childId) {
|
||||||
|
return 0x8000000000000000L | ((groupId & 0x7FFFFFFF) << 32) | (childId & 0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override this method if you foresee a clash in IDs based on this scheme:
|
||||||
|
* <p>
|
||||||
|
* Base implementation returns a long:
|
||||||
|
* <li> bit 0: Whether this ID points to a child (unset) or group (set), so for this method
|
||||||
|
* this bit will be 0.
|
||||||
|
* <li> bit 1-31: Lower 31 bits of the groupId
|
||||||
|
* <li> bit 32-63: Lower 32 bits of the childId.
|
||||||
|
* <p>
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public long getCombinedGroupId(long groupId) {
|
||||||
|
return (groupId & 0x7FFFFFFF) << 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
/*public boolean isEmpty() {
|
||||||
|
return getGroupCount() == 0;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @return 0 for any group or child position, since only one child type count is declared.
|
||||||
|
*/
|
||||||
|
public int getChildType(int groupPosition, int childPosition) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @return 1 as a default value in BaseExpandableListAdapter.
|
||||||
|
*/
|
||||||
|
public int getChildTypeCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @return 0 for any groupPosition, since only one group type count is declared.
|
||||||
|
*/
|
||||||
|
public int getGroupType(int groupPosition) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @return 1 as a default value in BaseExpandableListAdapter.
|
||||||
|
*/
|
||||||
|
public int getGroupTypeCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
209
src/api-impl/android/widget/ExpandableListAdapter.java
Normal file
209
src/api-impl/android/widget/ExpandableListAdapter.java
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.widget;
|
||||||
|
|
||||||
|
import android.database.DataSetObserver;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An adapter that links a {@link ExpandableListView} with the underlying
|
||||||
|
* data. The implementation of this interface will provide access
|
||||||
|
* to the data of the children (categorized by groups), and also instantiate
|
||||||
|
* {@link View}s for children and groups.
|
||||||
|
*/
|
||||||
|
public interface ExpandableListAdapter {
|
||||||
|
/**
|
||||||
|
* @see Adapter#registerDataSetObserver(DataSetObserver)
|
||||||
|
*/
|
||||||
|
void registerDataSetObserver(DataSetObserver observer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Adapter#unregisterDataSetObserver(DataSetObserver)
|
||||||
|
*/
|
||||||
|
void unregisterDataSetObserver(DataSetObserver observer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of groups.
|
||||||
|
*
|
||||||
|
* @return the number of groups
|
||||||
|
*/
|
||||||
|
int getGroupCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of children in a specified group.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group for which the children
|
||||||
|
* count should be returned
|
||||||
|
* @return the children count in the specified group
|
||||||
|
*/
|
||||||
|
int getChildrenCount(int groupPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data associated with the given group.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group
|
||||||
|
* @return the data child for the specified group
|
||||||
|
*/
|
||||||
|
Object getGroup(int groupPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data associated with the given child within the given group.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group that the child resides in
|
||||||
|
* @param childPosition the position of the child with respect to other
|
||||||
|
* children in the group
|
||||||
|
* @return the data of the child
|
||||||
|
*/
|
||||||
|
Object getChild(int groupPosition, int childPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ID for the group at the given position. This group ID must be
|
||||||
|
* unique across groups. The combined ID (see
|
||||||
|
* {@link #getCombinedGroupId(long)}) must be unique across ALL items
|
||||||
|
* (groups and all children).
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group for which the ID is wanted
|
||||||
|
* @return the ID associated with the group
|
||||||
|
*/
|
||||||
|
long getGroupId(int groupPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ID for the given child within the given group. This ID must be
|
||||||
|
* unique across all children within the group. The combined ID (see
|
||||||
|
* {@link #getCombinedChildId(long, long)}) must be unique across ALL items
|
||||||
|
* (groups and all children).
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group that contains the child
|
||||||
|
* @param childPosition the position of the child within the group for which
|
||||||
|
* the ID is wanted
|
||||||
|
* @return the ID associated with the child
|
||||||
|
*/
|
||||||
|
long getChildId(int groupPosition, int childPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the child and group IDs are stable across changes to the
|
||||||
|
* underlying data.
|
||||||
|
*
|
||||||
|
* @return whether or not the same ID always refers to the same object
|
||||||
|
* @see Adapter#hasStableIds()
|
||||||
|
*/
|
||||||
|
boolean hasStableIds();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a View that displays the given group. This View is only for the
|
||||||
|
* group--the Views for the group's children will be fetched using
|
||||||
|
* {@link #getChildView(int, int, boolean, View, ViewGroup)}.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group for which the View is
|
||||||
|
* returned
|
||||||
|
* @param isExpanded whether the group is expanded or collapsed
|
||||||
|
* @param convertView the old view to reuse, if possible. You should check
|
||||||
|
* that this view is non-null and of an appropriate type before
|
||||||
|
* using. If it is not possible to convert this view to display
|
||||||
|
* the correct data, this method can create a new view. It is not
|
||||||
|
* guaranteed that the convertView will have been previously
|
||||||
|
* created by
|
||||||
|
* {@link #getGroupView(int, boolean, View, ViewGroup)}.
|
||||||
|
* @param parent the parent that this view will eventually be attached to
|
||||||
|
* @return the View corresponding to the group at the specified position
|
||||||
|
*/
|
||||||
|
View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a View that displays the data for the given child within the given
|
||||||
|
* group.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group that contains the child
|
||||||
|
* @param childPosition the position of the child (for which the View is
|
||||||
|
* returned) within the group
|
||||||
|
* @param isLastChild Whether the child is the last child within the group
|
||||||
|
* @param convertView the old view to reuse, if possible. You should check
|
||||||
|
* that this view is non-null and of an appropriate type before
|
||||||
|
* using. If it is not possible to convert this view to display
|
||||||
|
* the correct data, this method can create a new view. It is not
|
||||||
|
* guaranteed that the convertView will have been previously
|
||||||
|
* created by
|
||||||
|
* {@link #getChildView(int, int, boolean, View, ViewGroup)}.
|
||||||
|
* @param parent the parent that this view will eventually be attached to
|
||||||
|
* @return the View corresponding to the child at the specified position
|
||||||
|
*/
|
||||||
|
View getChildView(int groupPosition, int childPosition, boolean isLastChild,
|
||||||
|
View convertView, ViewGroup parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the child at the specified position is selectable.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group that contains the child
|
||||||
|
* @param childPosition the position of the child within the group
|
||||||
|
* @return whether the child is selectable.
|
||||||
|
*/
|
||||||
|
boolean isChildSelectable(int groupPosition, int childPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListAdapter#areAllItemsEnabled()
|
||||||
|
*/
|
||||||
|
boolean areAllItemsEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListAdapter#isEmpty()
|
||||||
|
*/
|
||||||
|
boolean isEmpty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a group is expanded.
|
||||||
|
*
|
||||||
|
* @param groupPosition The group being expanded.
|
||||||
|
*/
|
||||||
|
void onGroupExpanded(int groupPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a group is collapsed.
|
||||||
|
*
|
||||||
|
* @param groupPosition The group being collapsed.
|
||||||
|
*/
|
||||||
|
void onGroupCollapsed(int groupPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an ID for a child that is unique across any item (either group or
|
||||||
|
* child) that is in this list. Expandable lists require each item (group or
|
||||||
|
* child) to have a unique ID among all children and groups in the list.
|
||||||
|
* This method is responsible for returning that unique ID given a child's
|
||||||
|
* ID and its group's ID. Furthermore, if {@link #hasStableIds()} is true, the
|
||||||
|
* returned ID must be stable as well.
|
||||||
|
*
|
||||||
|
* @param groupId The ID of the group that contains this child.
|
||||||
|
* @param childId The ID of the child.
|
||||||
|
* @return The unique (and possibly stable) ID of the child across all
|
||||||
|
* groups and children in this list.
|
||||||
|
*/
|
||||||
|
long getCombinedChildId(long groupId, long childId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an ID for a group that is unique across any item (either group or
|
||||||
|
* child) that is in this list. Expandable lists require each item (group or
|
||||||
|
* child) to have a unique ID among all children and groups in the list.
|
||||||
|
* This method is responsible for returning that unique ID given a group's
|
||||||
|
* ID. Furthermore, if {@link #hasStableIds()} is true, the returned ID must be
|
||||||
|
* stable as well.
|
||||||
|
*
|
||||||
|
* @param groupId The ID of the group
|
||||||
|
* @return The unique (and possibly stable) ID of the group across all
|
||||||
|
* groups and children in this list.
|
||||||
|
*/
|
||||||
|
long getCombinedGroupId(long groupId);
|
||||||
|
}
|
1044
src/api-impl/android/widget/ExpandableListConnector.java
Normal file
1044
src/api-impl/android/widget/ExpandableListConnector.java
Normal file
File diff suppressed because it is too large
Load diff
141
src/api-impl/android/widget/ExpandableListPosition.java
Normal file
141
src/api-impl/android/widget/ExpandableListPosition.java
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.widget;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ExpandableListPosition can refer to either a group's position or a child's
|
||||||
|
* position. Referring to a child's position requires both a group position (the
|
||||||
|
* group containing the child) and a child position (the child's position within
|
||||||
|
* that group). To create objects, use {@link #obtainChildPosition(int, int)} or
|
||||||
|
* {@link #obtainGroupPosition(int)}.
|
||||||
|
*/
|
||||||
|
class ExpandableListPosition {
|
||||||
|
|
||||||
|
private static final int MAX_POOL_SIZE = 5;
|
||||||
|
private static ArrayList<ExpandableListPosition> sPool =
|
||||||
|
new ArrayList<ExpandableListPosition>(MAX_POOL_SIZE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This data type represents a child position
|
||||||
|
*/
|
||||||
|
public final static int CHILD = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This data type represents a group position
|
||||||
|
*/
|
||||||
|
public final static int GROUP = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The position of either the group being referred to, or the parent
|
||||||
|
* group of the child being referred to
|
||||||
|
*/
|
||||||
|
public int groupPos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The position of the child within its parent group
|
||||||
|
*/
|
||||||
|
public int childPos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The position of the item in the flat list (optional, used internally when
|
||||||
|
* the corresponding flat list position for the group or child is known)
|
||||||
|
*/
|
||||||
|
int flatListPos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What type of position this ExpandableListPosition represents
|
||||||
|
*/
|
||||||
|
public int type;
|
||||||
|
|
||||||
|
private void resetState() {
|
||||||
|
groupPos = 0;
|
||||||
|
childPos = 0;
|
||||||
|
flatListPos = 0;
|
||||||
|
type = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExpandableListPosition() {
|
||||||
|
}
|
||||||
|
|
||||||
|
long getPackedPosition() {
|
||||||
|
if (type == CHILD)
|
||||||
|
return ExpandableListView.getPackedPositionForChild(groupPos, childPos);
|
||||||
|
else
|
||||||
|
return ExpandableListView.getPackedPositionForGroup(groupPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ExpandableListPosition obtainGroupPosition(int groupPosition) {
|
||||||
|
return obtain(GROUP, groupPosition, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ExpandableListPosition obtainChildPosition(int groupPosition, int childPosition) {
|
||||||
|
return obtain(CHILD, groupPosition, childPosition, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ExpandableListPosition obtainPosition(long packedPosition) {
|
||||||
|
if (packedPosition == ExpandableListView.PACKED_POSITION_VALUE_NULL) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpandableListPosition elp = getRecycledOrCreate();
|
||||||
|
elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition);
|
||||||
|
if (ExpandableListView.getPackedPositionType(packedPosition) ==
|
||||||
|
ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
|
||||||
|
elp.type = CHILD;
|
||||||
|
elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition);
|
||||||
|
} else {
|
||||||
|
elp.type = GROUP;
|
||||||
|
}
|
||||||
|
return elp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ExpandableListPosition obtain(int type, int groupPos, int childPos, int flatListPos) {
|
||||||
|
ExpandableListPosition elp = getRecycledOrCreate();
|
||||||
|
elp.type = type;
|
||||||
|
elp.groupPos = groupPos;
|
||||||
|
elp.childPos = childPos;
|
||||||
|
elp.flatListPos = flatListPos;
|
||||||
|
return elp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ExpandableListPosition getRecycledOrCreate() {
|
||||||
|
ExpandableListPosition elp;
|
||||||
|
synchronized (sPool) {
|
||||||
|
if (sPool.size() > 0) {
|
||||||
|
elp = sPool.remove(0);
|
||||||
|
} else {
|
||||||
|
return new ExpandableListPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elp.resetState();
|
||||||
|
return elp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not call this unless you obtained this via ExpandableListPosition.obtain().
|
||||||
|
* PositionMetadata will handle recycling its own children.
|
||||||
|
*/
|
||||||
|
public void recycle() {
|
||||||
|
synchronized (sPool) {
|
||||||
|
if (sPool.size() < MAX_POOL_SIZE) {
|
||||||
|
sPool.add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
106
src/api-impl/android/widget/HeterogeneousExpandableList.java
Normal file
106
src/api-impl/android/widget/HeterogeneousExpandableList.java
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.widget;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional methods that when implemented make an
|
||||||
|
* {@link ExpandableListAdapter} take advantage of the {@link Adapter} view type
|
||||||
|
* mechanism.
|
||||||
|
* <p>
|
||||||
|
* An {@link ExpandableListAdapter} declares it has one view type for its group items
|
||||||
|
* and one view type for its child items. Although adapted for most {@link ExpandableListView}s,
|
||||||
|
* these values should be tuned for heterogeneous {@link ExpandableListView}s.
|
||||||
|
* </p>
|
||||||
|
* Lists that contain different types of group and/or child item views, should use an adapter that
|
||||||
|
* implements this interface. This way, the recycled views that will be provided to
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||||
|
* and
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||||
|
* will be of the appropriate group or child type, resulting in a more efficient reuse of the
|
||||||
|
* previously created views.
|
||||||
|
*/
|
||||||
|
public interface HeterogeneousExpandableList {
|
||||||
|
/**
|
||||||
|
* Get the type of group View that will be created by
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||||
|
* . for the specified group item.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group for which the type should be returned.
|
||||||
|
* @return An integer representing the type of group View. Two group views should share the same
|
||||||
|
* type if one can be converted to the other in
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||||
|
* . Note: Integers must be in the range 0 to {@link #getGroupTypeCount} - 1.
|
||||||
|
* {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
|
||||||
|
* @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
|
||||||
|
* @see #getGroupTypeCount()
|
||||||
|
*/
|
||||||
|
int getGroupType(int groupPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of child View that will be created by
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||||
|
* for the specified child item.
|
||||||
|
*
|
||||||
|
* @param groupPosition the position of the group that the child resides in
|
||||||
|
* @param childPosition the position of the child with respect to other children in the group
|
||||||
|
* @return An integer representing the type of child View. Two child views should share the same
|
||||||
|
* type if one can be converted to the other in
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||||
|
* Note: Integers must be in the range 0 to {@link #getChildTypeCount} - 1.
|
||||||
|
* {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
|
||||||
|
* @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
|
||||||
|
* @see #getChildTypeCount()
|
||||||
|
*/
|
||||||
|
int getChildType(int groupPosition, int childPosition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Returns the number of types of group Views that will be created by
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||||
|
* . Each type represents a set of views that can be converted in
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
|
||||||
|
* . If the adapter always returns the same type of View for all group items, this method should
|
||||||
|
* return 1.
|
||||||
|
* </p>
|
||||||
|
* This method will only be called when the adapter is set on the {@link AdapterView}.
|
||||||
|
*
|
||||||
|
* @return The number of types of group Views that will be created by this adapter.
|
||||||
|
* @see #getChildTypeCount()
|
||||||
|
* @see #getGroupType(int)
|
||||||
|
*/
|
||||||
|
int getGroupTypeCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Returns the number of types of child Views that will be created by
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||||
|
* . Each type represents a set of views that can be converted in
|
||||||
|
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
|
||||||
|
* , for any group. If the adapter always returns the same type of View for
|
||||||
|
* all child items, this method should return 1.
|
||||||
|
* </p>
|
||||||
|
* This method will only be called when the adapter is set on the {@link AdapterView}.
|
||||||
|
*
|
||||||
|
* @return The total number of types of child Views that will be created by this adapter.
|
||||||
|
* @see #getGroupTypeCount()
|
||||||
|
* @see #getChildType(int, int)
|
||||||
|
*/
|
||||||
|
int getChildTypeCount();
|
||||||
|
}
|
|
@ -549,6 +549,7 @@ srcs = [
|
||||||
'android/widget/ArrayAdapter.java',
|
'android/widget/ArrayAdapter.java',
|
||||||
'android/widget/AutoCompleteTextView.java',
|
'android/widget/AutoCompleteTextView.java',
|
||||||
'android/widget/BaseAdapter.java',
|
'android/widget/BaseAdapter.java',
|
||||||
|
'android/widget/BaseExpandableListAdapter.java',
|
||||||
'android/widget/Button.java',
|
'android/widget/Button.java',
|
||||||
'android/widget/CheckBox.java',
|
'android/widget/CheckBox.java',
|
||||||
'android/widget/Checkable.java',
|
'android/widget/Checkable.java',
|
||||||
|
@ -557,6 +558,9 @@ srcs = [
|
||||||
'android/widget/CursorAdapter.java',
|
'android/widget/CursorAdapter.java',
|
||||||
'android/widget/EdgeEffect.java',
|
'android/widget/EdgeEffect.java',
|
||||||
'android/widget/EditText.java',
|
'android/widget/EditText.java',
|
||||||
|
'android/widget/ExpandableListAdapter.java',
|
||||||
|
'android/widget/ExpandableListConnector.java',
|
||||||
|
'android/widget/ExpandableListPosition.java',
|
||||||
'android/widget/ExpandableListView.java',
|
'android/widget/ExpandableListView.java',
|
||||||
'android/widget/Filter.java',
|
'android/widget/Filter.java',
|
||||||
'android/widget/Filterable.java',
|
'android/widget/Filterable.java',
|
||||||
|
@ -565,6 +569,7 @@ srcs = [
|
||||||
'android/widget/Gallery.java',
|
'android/widget/Gallery.java',
|
||||||
'android/widget/GridView.java',
|
'android/widget/GridView.java',
|
||||||
'android/widget/HeaderViewListAdapter.java',
|
'android/widget/HeaderViewListAdapter.java',
|
||||||
|
'android/widget/HeterogeneousExpandableList.java',
|
||||||
'android/widget/HorizontalScrollView.java',
|
'android/widget/HorizontalScrollView.java',
|
||||||
'android/widget/ImageButton.java',
|
'android/widget/ImageButton.java',
|
||||||
'android/widget/ImageView.java',
|
'android/widget/ImageView.java',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue