Merge "Fixed race condition regarding first child max height"
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 d9e7f66..8757d57 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java
@@ -542,9 +542,13 @@
                                 public void onLayoutChange(View v, int left, int top, int right,
                                         int bottom, int oldLeft, int oldTop, int oldRight,
                                         int oldBottom) {
-                                    mFirstChildMaxHeight = getMaxAllowedChildHeight(
-                                            mFirstChildWhileExpanding);
-                                    mFirstChildWhileExpanding.removeOnLayoutChangeListener(this);
+                                    if (mFirstChildWhileExpanding != null) {
+                                        mFirstChildMaxHeight = getMaxAllowedChildHeight(
+                                                mFirstChildWhileExpanding);
+                                    } else {
+                                        mFirstChildMaxHeight = 0;
+                                    }
+                                    v.removeOnLayoutChangeListener(this);
                                 }
                             });
                 } else {