Program: 175948
Project: 175948
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  ArrayList<Rect> bounds=calculateAllBounds(paintText);
  int count=(viewFlow != null && viewFlow.getAdapter() != null) ? viewFlow.getAdapter().getCount() : 1;
  Rect curViewBound=bounds.get(currentPosition);
  int curViewWidth=curViewBound.right - curViewBound.left;
  if (curViewBound.left < 0) {
    clipViewOnTheLeft(curViewBound,curViewWidth);
  }
  if (curViewBound.right > getLeft() + getWidth()) {
    clipViewOnTheRight(curViewBound,curViewWidth);
  }
  if (currentPosition > 0) {
    for (int iLoop=currentPosition - 1; iLoop >= 0; iLoop--) {
      Rect bound=bounds.get(iLoop);
      int w=bound.right - bound.left;
      if (bound.left < 0) {
        clipViewOnTheLeft(bound,w);
        if (iLoop < count - 1 && currentPosition != iLoop) {
          Rect rightBound=bounds.get(iLoop + 1);
          if (bound.right + TITLE_PADDING > rightBound.left) {
            bound.left=rightBound.left - (w + (int)titlePadding);
          }
        }
      }
    }
  }
  if (currentPosition < count - 1) {
    for (int iLoop=currentPosition + 1; iLoop < count; iLoop++) {
      Rect bound=bounds.get(iLoop);
      int w=bound.right - bound.left;
      if (bound.right > getLeft() + getWidth()) {
        clipViewOnTheRight(bound,w);
        if (iLoop > 0 && currentPosition != iLoop) {
          Rect leftBound=bounds.get(iLoop - 1);
          if (bound.left - TITLE_PADDING < leftBound.right) {
            bound.left=leftBound.right + (int)titlePadding;
          }
        }
      }
    }
  }
  for (int iLoop=0; iLoop < count; iLoop++) {
    String title=getTitle(iLoop);
    Rect bound=bounds.get(iLoop);
    if ((bound.left > getLeft() && bound.left < getLeft() + getWidth()) || (bound.right > getLeft() && bound.right < getLeft() + getWidth())) {
      Paint paint=paintText;
      int middle=(bound.left + bound.right) / 2;
      if (Math.abs(middle - (getWidth() / 2)) < 20) {
        paint=paintSelected;
      }
      canvas.drawText(title,bound.left,bound.bottom,paint);
    }
  }
  path=new Path();
  path.moveTo(0,getHeight() - footerLineHeight);
  path.lineTo(getWidth(),getHeight() - footerLineHeight);
  path.close();
  canvas.drawPath(path,paintFooterLine);
  path=new Path();
  path.moveTo(getWidth() / 2,getHeight() - footerLineHeight - footerTriangleHeight);
  path.lineTo(getWidth() / 2 + footerTriangleHeight,getHeight() - footerLineHeight);
  path.lineTo(getWidth() / 2 - footerTriangleHeight,getHeight() - footerLineHeight);
  path.close();
  canvas.drawPath(path,paintFooterTriangle);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  ArrayList<Rect> bounds=calculateAllBounds(paintText);
  int count=(viewFlow != null && viewFlow.getAdapter() != null) ? viewFlow.getAdapter().getCount() : 1;
  Rect curViewBound=bounds.get(currentPosition);
  int curViewWidth=curViewBound.right - curViewBound.left;
  if (curViewBound.left < 0) {
    clipViewOnTheLeft(curViewBound,curViewWidth);
  }
  if (curViewBound.right > getLeft() + getWidth()) {
    clipViewOnTheRight(curViewBound,curViewWidth);
  }
  if (currentPosition > 0) {
    for (int iLoop=currentPosition - 1; iLoop >= 0; iLoop--) {
      Rect bound=bounds.get(iLoop);
      int w=bound.right - bound.left;
      if (bound.left < 0) {
        clipViewOnTheLeft(bound,w);
        if (iLoop < count - 1 && currentPosition != iLoop) {
          Rect rightBound=bounds.get(iLoop + 1);
          if (bound.right + TITLE_PADDING > rightBound.left) {
            bound.left=rightBound.left - (w + (int)titlePadding);
          }
        }
      }
    }
  }
  if (currentPosition < count - 1) {
    for (int iLoop=currentPosition + 1; iLoop < count; iLoop++) {
      Rect bound=bounds.get(iLoop);
      int w=bound.right - bound.left;
      if (bound.right > getLeft() + getWidth()) {
        clipViewOnTheRight(bound,w);
        if (iLoop > 0 && currentPosition != iLoop) {
          Rect leftBound=bounds.get(iLoop - 1);
          if (bound.left - TITLE_PADDING < leftBound.right) {
            bound.left=leftBound.right + (int)titlePadding;
          }
        }
      }
    }
  }
  for (int iLoop=0; iLoop < count; iLoop++) {
    String title=getTitle(iLoop);
    Rect bound=bounds.get(iLoop);
    if ((bound.left > getLeft() && bound.left < getLeft() + getWidth()) || (bound.right > getLeft() && bound.right < getLeft() + getWidth())) {
      Paint paint=paintText;
      int middle=(bound.left + bound.right) / 2;
      if (Math.abs(middle - (getWidth() / 2)) < 20) {
        paint=paintSelected;
      }
      canvas.drawText(title,bound.left,bound.bottom,paint);
    }
  }
  path=new Path();
  int coordY=getHeight() - 1;
  coordY-=(footerLineHeight % 2 == 1) ? footerLineHeight / 2 : footerLineHeight / 2 - 1;
  path.moveTo(0,coordY);
  path.lineTo(getWidth(),coordY);
  path.close();
  canvas.drawPath(path,paintFooterLine);
  path=new Path();
  path.moveTo(getWidth() / 2,getHeight() - footerLineHeight - footerTriangleHeight);
  path.lineTo(getWidth() / 2 + footerTriangleHeight,getHeight() - footerLineHeight);
  path.lineTo(getWidth() / 2 - footerTriangleHeight,getHeight() - footerLineHeight);
  path.close();
  canvas.drawPath(path,paintFooterTriangle);
}