Program: 199840
Project: 199840
Buggy source:
/** 
 * Updates the title and selected month if the <code>view</code> has moved to a new month.
 */
private void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  WeekView child=(WeekView)view.getChildAt(0);
  if (child == null) {
    return;
  }
  long currScroll=view.getFirstVisiblePosition() * child.getHeight() - child.getBottom();
  if (currScroll < mPreviousScrollPosition) {
    mIsScrollingUp=true;
  }
 else   if (currScroll > mPreviousScrollPosition) {
    mIsScrollingUp=false;
  }
 else {
    return;
  }
  int offset=child.getBottom() < mWeekMinVisibleHeight ? 1 : 0;
  if (mIsScrollingUp) {
    child=(WeekView)view.getChildAt(SCROLL_HYST_WEEKS + offset);
  }
 else   if (offset != 0) {
    child=(WeekView)view.getChildAt(offset);
  }
  int month;
  if (mIsScrollingUp) {
    month=child.getMonthOfFirstWeekDay();
  }
 else {
    month=child.getMonthOfLastWeekDay();
  }
  int monthDiff;
  if (mCurrentMonthDisplayed == 11 && month == 0) {
    monthDiff=1;
  }
 else   if (mCurrentMonthDisplayed == 0 && month == 11) {
    monthDiff=-1;
  }
 else {
    monthDiff=month - mCurrentMonthDisplayed;
  }
  if ((!mIsScrollingUp && monthDiff > 0) || (mIsScrollingUp && monthDiff < 0)) {
    Calendar firstDay=child.getFirstDay();
    if (mIsScrollingUp) {
      firstDay.add(Calendar.DAY_OF_MONTH,-DAYS_PER_WEEK);
    }
 else {
      firstDay.add(Calendar.DAY_OF_MONTH,DAYS_PER_WEEK);
    }
    setMonthDisplayed(firstDay);
  }
  mPreviousScrollPosition=currScroll;
  mPreviousScrollState=mCurrentScrollState;
}

Fixed version (ground truth):
/** 
 * Updates the title and selected month if the <code>view</code> has moved to a new month.
 */
private void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  WeekView child=(WeekView)view.getChildAt(0);
  if (child == null) {
    return;
  }
  long currScroll=view.getFirstVisiblePosition() * child.getHeight() - child.getBottom();
  if (currScroll < mPreviousScrollPosition) {
    mIsScrollingUp=true;
  }
 else   if (currScroll > mPreviousScrollPosition) {
    mIsScrollingUp=false;
  }
 else {
    return;
  }
  int offset=child.getBottom() < mWeekMinVisibleHeight ? 1 : 0;
  if (mIsScrollingUp) {
    child=(WeekView)view.getChildAt(SCROLL_HYST_WEEKS + offset);
  }
 else   if (offset != 0) {
    child=(WeekView)view.getChildAt(offset);
  }
  if (child != null) {
    int month;
    if (mIsScrollingUp) {
      month=child.getMonthOfFirstWeekDay();
    }
 else {
      month=child.getMonthOfLastWeekDay();
    }
    int monthDiff;
    if (mCurrentMonthDisplayed == 11 && month == 0) {
      monthDiff=1;
    }
 else     if (mCurrentMonthDisplayed == 0 && month == 11) {
      monthDiff=-1;
    }
 else {
      monthDiff=month - mCurrentMonthDisplayed;
    }
    if ((!mIsScrollingUp && monthDiff > 0) || (mIsScrollingUp && monthDiff < 0)) {
      Calendar firstDay=child.getFirstDay();
      if (mIsScrollingUp) {
        firstDay.add(Calendar.DAY_OF_MONTH,-DAYS_PER_WEEK);
      }
 else {
        firstDay.add(Calendar.DAY_OF_MONTH,DAYS_PER_WEEK);
      }
      setMonthDisplayed(firstDay);
    }
  }
  mPreviousScrollPosition=currScroll;
  mPreviousScrollState=mCurrentScrollState;
}