New HeterogeneousExpandableList interface.
This interface can be used in conjunction with ExpandableListAdapter to
declare more types of child and/or group views.
None of the ExpandableListAdapter implementations is heterogeneous in the
framework. BaseExpandableListAdapter was decalred to use this interface so that users
see the methods and can overload. DateSortedExpandableListAdapter was left unchanged.
This feature is related to http://b/issue?id=1459940
Change-Id: Ifc589b697913778b16abfdcaaa9f8f81e564add7
diff --git a/core/java/android/widget/BaseExpandableListAdapter.java b/core/java/android/widget/BaseExpandableListAdapter.java
index 1bba7f0..396b7ae 100644
--- a/core/java/android/widget/BaseExpandableListAdapter.java
+++ b/core/java/android/widget/BaseExpandableListAdapter.java
@@ -18,7 +18,6 @@
import android.database.DataSetObservable;
import android.database.DataSetObserver;
-import android.view.KeyEvent;
/**
* Base class for a {@link ExpandableListAdapter} used to provide data and Views
@@ -31,7 +30,8 @@
* @see SimpleExpandableListAdapter
* @see SimpleCursorTreeAdapter
*/
-public abstract class BaseExpandableListAdapter implements ExpandableListAdapter {
+public abstract class BaseExpandableListAdapter implements ExpandableListAdapter,
+ HeterogeneousExpandableList {
private final DataSetObservable mDataSetObservable = new DataSetObservable();
public void registerDataSetObserver(DataSetObserver observer) {
@@ -102,5 +102,37 @@
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;
+ }
}