summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alan Viverette <alanv@google.com> 2013-06-04 22:48:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2013-06-04 22:48:20 +0000
commit4bb52a93e9803a62e32fa5cd6f99a7d0135dac3e (patch)
treef3659951c50f25165339bc5cfedc4f4de8be4472
parent8b85e7b04c8683dc65e9c609de2d43f3c00774a9 (diff)
parentb9fc4b879bab5640038fb09b40133611f91d7274 (diff)
Merge "Always draw dividers for footers and headers when explicitly enabled."
-rw-r--r--core/java/android/widget/ListView.java60
1 files changed, 38 insertions, 22 deletions
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index a82bebd3828b..001d99c49970 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -3208,7 +3208,7 @@ public class ListView extends AbsListView {
final int count = getChildCount();
final int headerCount = mHeaderViewInfos.size();
final int itemCount = mItemCount;
- final int footerLimit = itemCount - mFooterViewInfos.size() - 1;
+ final int footerLimit = (itemCount - mFooterViewInfos.size());
final boolean headerDividers = mHeaderDividersEnabled;
final boolean footerDividers = mFooterDividersEnabled;
final int first = mFirstPosition;
@@ -3252,17 +3252,25 @@ public class ListView extends AbsListView {
}
for (int i = 0; i < count; i++) {
- if ((headerDividers || first + i >= headerCount) &&
- (footerDividers || first + i < footerLimit)) {
- View child = getChildAt(i);
+ final int itemIndex = (first + i);
+ final boolean isHeader = (itemIndex < headerCount);
+ final boolean isFooter = (itemIndex >= footerLimit);
+ if ((headerDividers || !isHeader) && (footerDividers || !isFooter)) {
+ final View child = getChildAt(i);
bottom = child.getBottom();
- // Don't draw dividers next to items that are not enabled
-
- if (drawDividers &&
- (bottom < listBottom && !(drawOverscrollFooter && i == count - 1))) {
- if ((areAllItemsSelectable ||
- (adapter.isEnabled(first + i) && (i == count - 1 ||
- adapter.isEnabled(first + i + 1))))) {
+ final boolean isLastItem = (i == (count - 1));
+
+ if (drawDividers && (bottom < listBottom)
+ && !(drawOverscrollFooter && isLastItem)) {
+ final int nextIndex = (itemIndex + 1);
+ // Draw dividers between enabled items, headers and/or
+ // footers when enabled, and the end of the list.
+ if (areAllItemsSelectable || ((adapter.isEnabled(itemIndex)
+ || (headerDividers && isHeader)
+ || (footerDividers && isFooter)) && (isLastItem
+ || adapter.isEnabled(nextIndex)
+ || (headerDividers && (nextIndex < headerCount))
+ || (footerDividers && (nextIndex >= footerLimit))))) {
bounds.top = bottom;
bounds.bottom = bottom + dividerHeight;
drawDivider(canvas, bounds, i);
@@ -3295,20 +3303,28 @@ public class ListView extends AbsListView {
final int start = drawOverscrollHeader ? 1 : 0;
for (int i = start; i < count; i++) {
- if ((headerDividers || first + i >= headerCount) &&
- (footerDividers || first + i < footerLimit)) {
- View child = getChildAt(i);
+ final int itemIndex = (first + i);
+ final boolean isHeader = (itemIndex < headerCount);
+ final boolean isFooter = (itemIndex >= footerLimit);
+ if ((headerDividers || !isHeader) && (footerDividers || !isFooter)) {
+ final View child = getChildAt(i);
top = child.getTop();
- // Don't draw dividers next to items that are not enabled
- if (top > effectivePaddingTop) {
- if ((areAllItemsSelectable ||
- (adapter.isEnabled(first + i) && (i == count - 1 ||
- adapter.isEnabled(first + i + 1))))) {
+ if (drawDividers && (top > effectivePaddingTop)) {
+ final boolean isFirstItem = (i == start);
+ final int previousIndex = (itemIndex - 1);
+ // Draw dividers between enabled items, headers and/or
+ // footers when enabled, and the end of the list.
+ if (areAllItemsSelectable || ((adapter.isEnabled(itemIndex)
+ || (headerDividers && isHeader)
+ || (footerDividers && isFooter)) && (isFirstItem
+ || adapter.isEnabled(previousIndex)
+ || (headerDividers && (previousIndex < headerCount))
+ || (footerDividers && (previousIndex >= footerLimit))))) {
bounds.top = top - dividerHeight;
bounds.bottom = top;
- // Give the method the child ABOVE the divider, so we
- // subtract one from our child
- // position. Give -1 when there is no child above the
+ // Give the method the child ABOVE the divider,
+ // so we subtract one from our child position.
+ // Give -1 when there is no child above the
// divider.
drawDivider(canvas, bounds, i - 1);
} else if (fillForMissingDividers) {