summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2010-03-23 16:44:48 -0700
committerJean-Baptiste Queru <jbq@google.com>2010-03-24 15:27:41 -0700
commit478a745e8421497bad9ea0cbd75bc4d4d419ef60 (patch)
tree4855357e48b331eb71609364a8a7b1d66098fd3c /core/java/android/widget
parent26295d20e3e41f33757043615487f82eab8e14a6 (diff)
downloadframeworks_base-478a745e8421497bad9ea0cbd75bc4d4d419ef60.zip
frameworks_base-478a745e8421497bad9ea0cbd75bc4d4d419ef60.tar.gz
frameworks_base-478a745e8421497bad9ea0cbd75bc4d4d419ef60.tar.bz2
null header and footer allowed in HeaderViewListAdapter.
The view infos should never be null since they are created by ListView, which is the natural and only use of this class. However, some tests in CTS pass null pointers. Replace null by a static empty list. http://b/issue?id=2527753 Change-Id: I9b92fa018c89007f12be899285f75130b2c8ac40
Diffstat (limited to 'core/java/android/widget')
-rw-r--r--core/java/android/widget/HeaderViewListAdapter.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/core/java/android/widget/HeaderViewListAdapter.java b/core/java/android/widget/HeaderViewListAdapter.java
index ca97987..e2a269e 100644
--- a/core/java/android/widget/HeaderViewListAdapter.java
+++ b/core/java/android/widget/HeaderViewListAdapter.java
@@ -31,15 +31,21 @@ import java.util.ArrayList;
*/
public class HeaderViewListAdapter implements WrapperListAdapter, Filterable {
- private ListAdapter mAdapter;
+ private final ListAdapter mAdapter;
// These two ArrayList are assumed to NOT be null.
- // They are indeed created when declared in ListView and then shared.
+ // They are indeed created when declared in ListView and then shared.
ArrayList<ListView.FixedViewInfo> mHeaderViewInfos;
ArrayList<ListView.FixedViewInfo> mFooterViewInfos;
+
+ // Used as a placeholder in case the provided info views are indeed null.
+ // Currently only used by some CTS tests, which may be removed.
+ static final ArrayList<ListView.FixedViewInfo> EMPTY_INFO_LIST =
+ new ArrayList<ListView.FixedViewInfo>();
+
boolean mAreAllFixedViewsSelectable;
- private boolean mIsFilterable;
+ private final boolean mIsFilterable;
public HeaderViewListAdapter(ArrayList<ListView.FixedViewInfo> headerViewInfos,
ArrayList<ListView.FixedViewInfo> footerViewInfos,
@@ -47,8 +53,17 @@ public class HeaderViewListAdapter implements WrapperListAdapter, Filterable {
mAdapter = adapter;
mIsFilterable = adapter instanceof Filterable;
- mHeaderViewInfos = headerViewInfos;
- mFooterViewInfos = footerViewInfos;
+ if (headerViewInfos == null) {
+ mHeaderViewInfos = EMPTY_INFO_LIST;
+ } else {
+ mHeaderViewInfos = headerViewInfos;
+ }
+
+ if (footerViewInfos == null) {
+ mFooterViewInfos = EMPTY_INFO_LIST;
+ } else {
+ mFooterViewInfos = footerViewInfos;
+ }
mAreAllFixedViewsSelectable =
areAllListInfosSelectable(mHeaderViewInfos)