Program: 192275
Project: 192275
Buggy source:
/** 
 * Determine the positions for the views. This is the main part of the algorithm.
 * @param resultState The result state to update if a change to the properties of a child occurs
 * @param algorithmState The state in which the current pass of the algorithm is currently in
 * @param ambientState The current ambient state
 */
private void updatePositionsForState(StackScrollState resultState,StackScrollAlgorithmState algorithmState,AmbientState ambientState){
  float bottomPeekStart=ambientState.getInnerHeight() - mBottomStackPeekSize;
  float bottomStackStart=bottomPeekStart - mBottomStackSlowDownLength;
  float currentYPosition=-algorithmState.scrollY;
  int childCount=algorithmState.visibleChildren.size();
  int paddingAfterChild;
  for (int i=0; i < childCount; i++) {
    ExpandableView child=algorithmState.visibleChildren.get(i);
    StackViewState childViewState=resultState.getViewStateForView(child);
    childViewState.location=StackViewState.LOCATION_UNKNOWN;
    paddingAfterChild=getPaddingAfterChild(algorithmState,child);
    int childHeight=getMaxAllowedChildHeight(child);
    int minHeight=child.getMinHeight();
    childViewState.yTranslation=currentYPosition;
    if (i == 0) {
      updateFirstChildHeight(child,childViewState,childHeight,ambientState);
    }
    float nextYPosition=currentYPosition + childHeight + paddingAfterChild;
    if (nextYPosition >= bottomStackStart) {
      if (currentYPosition >= bottomStackStart) {
        updateStateForChildFullyInBottomStack(algorithmState,bottomStackStart,childViewState,minHeight,ambientState,child);
      }
 else {
        updateStateForChildTransitioningInBottom(algorithmState,bottomStackStart,child,currentYPosition,childViewState,childHeight);
      }
    }
 else {
      childViewState.location=StackViewState.LOCATION_MAIN_AREA;
      clampPositionToBottomStackStart(childViewState,childViewState.height,childHeight,ambientState);
    }
    if (i == 0 && ambientState.getScrollY() <= 0) {
      childViewState.yTranslation=Math.max(0,childViewState.yTranslation);
    }
    currentYPosition=childViewState.yTranslation + childHeight + paddingAfterChild;
    if (currentYPosition <= 0) {
      childViewState.location=StackViewState.LOCATION_HIDDEN_TOP;
    }
    if (childViewState.location == StackViewState.LOCATION_UNKNOWN) {
      Log.wtf(LOG_TAG,"String_Node_Str" + i);
    }
    childViewState.yTranslation+=ambientState.getTopPadding() + ambientState.getStackTranslation();
  }
}

Fixed version (ground truth):
/** 
 * Determine the positions for the views. This is the main part of the algorithm.
 * @param resultState The result state to update if a change to the properties of a child occurs
 * @param algorithmState The state in which the current pass of the algorithm is currently in
 * @param ambientState The current ambient state
 */
private void updatePositionsForState(StackScrollState resultState,StackScrollAlgorithmState algorithmState,AmbientState ambientState){
  float bottomPeekStart=ambientState.getInnerHeight() - mBottomStackPeekSize;
  float bottomStackStart=bottomPeekStart - mBottomStackSlowDownLength;
  float currentYPosition=-algorithmState.scrollY;
  int childCount=algorithmState.visibleChildren.size();
  int paddingAfterChild;
  for (int i=0; i < childCount; i++) {
    ExpandableView child=algorithmState.visibleChildren.get(i);
    StackViewState childViewState=resultState.getViewStateForView(child);
    childViewState.location=StackViewState.LOCATION_UNKNOWN;
    paddingAfterChild=getPaddingAfterChild(algorithmState,child);
    int childHeight=getMaxAllowedChildHeight(child);
    int collapsedHeight=child.getCollapsedHeight();
    childViewState.yTranslation=currentYPosition;
    if (i == 0) {
      updateFirstChildHeight(child,childViewState,childHeight,ambientState);
    }
    float nextYPosition=currentYPosition + childHeight + paddingAfterChild;
    if (nextYPosition >= bottomStackStart) {
      if (currentYPosition >= bottomStackStart) {
        updateStateForChildFullyInBottomStack(algorithmState,bottomStackStart,childViewState,collapsedHeight,ambientState,child);
      }
 else {
        updateStateForChildTransitioningInBottom(algorithmState,bottomStackStart,child,currentYPosition,childViewState,childHeight);
      }
    }
 else {
      childViewState.location=StackViewState.LOCATION_MAIN_AREA;
      clampPositionToBottomStackStart(childViewState,childViewState.height,childHeight,ambientState);
    }
    if (i == 0 && ambientState.getScrollY() <= 0) {
      childViewState.yTranslation=Math.max(0,childViewState.yTranslation);
    }
    currentYPosition=childViewState.yTranslation + childHeight + paddingAfterChild;
    if (currentYPosition <= 0) {
      childViewState.location=StackViewState.LOCATION_HIDDEN_TOP;
    }
    if (childViewState.location == StackViewState.LOCATION_UNKNOWN) {
      Log.wtf(LOG_TAG,"String_Node_Str" + i);
    }
    childViewState.yTranslation+=ambientState.getTopPadding() + ambientState.getStackTranslation();
  }
}