Fix first child handling with GONE children.
Bug: 13635952
Change-Id: I970f39a2a33d957f32d3290999fd007f0d323b3b
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
index 626cf86..431f6fe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -415,11 +415,9 @@
*/
private void updateZValuesForState(StackScrollState resultState,
StackScrollAlgorithmState algorithmState) {
- ViewGroup hostView = resultState.getHostView();
int childCount = algorithmState.visibleChildren.size();
for (int i = 0; i < childCount; i++) {
View child = algorithmState.visibleChildren.get(i);
- if (child.getVisibility() == View.GONE) continue;
StackScrollState.ViewState childViewState = resultState.getViewStateForView(child);
if (i < algorithmState.itemsInTopStack) {
float stackIndex = algorithmState.itemsInTopStack - i;
@@ -453,8 +451,8 @@
}
private void updateFirstChildHeightWhileExpanding(ViewGroup hostView) {
- if (hostView.getChildCount() > 0) {
- mFirstChildWhileExpanding = hostView.getChildAt(0);
+ mFirstChildWhileExpanding = findFirstVisibleChild(hostView);
+ if (mFirstChildWhileExpanding != null) {
if (mExpandedOnStart) {
// We are collapsing the shade, so the first child can get as most as high as the
@@ -466,11 +464,21 @@
mFirstChildMaxHeight = getMaxAllowedChildHeight(mFirstChildWhileExpanding);
}
} else {
- mFirstChildWhileExpanding = null;
mFirstChildMaxHeight = 0;
}
}
+ private View findFirstVisibleChild(ViewGroup container) {
+ int childCount = container.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View child = container.getChildAt(i);
+ if (child.getVisibility() != View.GONE) {
+ return child;
+ }
+ }
+ return null;
+ }
+
public void onExpansionStopped() {
mIsExpansionChanging = false;
mFirstChildWhileExpanding = null;