Program: 32643
Project: 32643
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.date_picker);
  getCurrentDate();
  findCalendarForCurrentMonth();
  mMonthListview=(ListView)findViewById(R.id.month_listview);
  mDateListView=(ListView)findViewById(R.id.date_listview);
  mYearListView=(ListView)findViewById(R.id.year_listview);
  initializeObjects();
  String monthNames[]=getResources().getStringArray(R.array.month_names);
  mMonthAdapter=new MonthYearAdapter(this,monthNames,monthNames.length,Constants.NOT_FOR_DATE_VIEW);
  mMonthAdapter.setAllItemsVisible(true);
  mYearAdapter=new MonthYearAdapter(this,null,Constants.NO_OF_YEARS,Constants.NOT_FOR_DATE_VIEW);
  mDateAdapter=new MonthYearAdapter(this,daysOfTheMonth,daysOfTheMonth.length,Constants.FOR_DATE_VIEW);
  mDateAdapter.setCurrentMonth(mCurrentMonth);
  mDateAdapter.setCurrentYear(mCurrentYear);
  mYearAdapter.setAllItemsVisible(false);
  mDateAdapter.setAllItemsVisible(false);
  mMonthListview.setAdapter(mMonthAdapter);
  mYearListView.setAdapter(mYearAdapter);
  mDateListView.setAdapter(mDateAdapter);
  setCurrentPositionsInListViews();
  final RelativeLayout rootLayout=(RelativeLayout)findViewById(R.id.root_layout);
  ViewTreeObserver vto=rootLayout.getViewTreeObserver();
  vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
    @Override public void onGlobalLayout(){
      rootLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
      mRootLayoutHeight=rootLayout.getMeasuredHeight();
      mMonthListview.setSelectionFromTop(mCurrentMonthPosition,mRootLayoutHeight / 3);
      mYearListView.setSelectionFromTop(mCurrentYearPosition,mRootLayoutHeight / 3);
      mDateListView.setSelectionFromTop(mCurrentDatePosition,mRootLayoutHeight / 3);
      setListenersOnListView(mMonthAdapter,mMonthListview,mMonthListBeingTouched,mScrollStateOfMonthView,mMonthViewVisible);
      setListenersOnListView(mYearAdapter,mYearListView,mYearListBeingTouched,mScrollStateOfYearView,mYearViewVisible);
      setListenersOnListView(mDateAdapter,mDateListView,mDateListBeingTouched,mScrollStateOfDayView,mDateViewVisible);
      mMiddlePositionFromTop=mCurrentMonthPosition - mMonthListview.getFirstVisiblePosition();
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.date_picker);
  getCurrentDate();
  findCalendarForCurrentMonth(mCurrentYear,mCurrentMonth + 1);
  mMonthListview=(ListView)findViewById(R.id.month_listview);
  mDateListView=(ListView)findViewById(R.id.date_listview);
  mYearListView=(ListView)findViewById(R.id.year_listview);
  initializeObjects();
  String monthNames[]=getResources().getStringArray(R.array.month_names);
  mMonthAdapter=new MonthYearAdapter(this,monthNames,monthNames.length,Constants.NOT_FOR_DATE_VIEW);
  mMonthAdapter.setAllItemsVisible(true);
  mYearAdapter=new MonthYearAdapter(this,null,Constants.NO_OF_YEARS,Constants.NOT_FOR_DATE_VIEW);
  mDateAdapter=new MonthYearAdapter(this,daysOfTheMonth,daysOfTheMonth.length,Constants.FOR_DATE_VIEW);
  mDateAdapter.setCurrentMonth(mCurrentMonth);
  mDateAdapter.setCurrentYear(mCurrentYear);
  mYearAdapter.setAllItemsVisible(false);
  mDateAdapter.setAllItemsVisible(false);
  mMonthListview.setAdapter(mMonthAdapter);
  mYearListView.setAdapter(mYearAdapter);
  mDateListView.setAdapter(mDateAdapter);
  setCurrentPositionsInListViews();
  final RelativeLayout rootLayout=(RelativeLayout)findViewById(R.id.root_layout);
  ViewTreeObserver vto=rootLayout.getViewTreeObserver();
  vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
    @Override public void onGlobalLayout(){
      rootLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
      mRootLayoutHeight=rootLayout.getMeasuredHeight();
      mMonthListview.setSelectionFromTop(mCurrentMonthPosition,mRootLayoutHeight / 3);
      mYearListView.setSelectionFromTop(mCurrentYearPosition,mRootLayoutHeight / 3);
      mDateListView.setSelectionFromTop(mCurrentDatePosition,mRootLayoutHeight / 3);
      setListenersOnListView(mMonthAdapter,mMonthListview,mMonthListBeingTouched,mScrollStateOfMonthView,mMonthViewVisible);
      setListenersOnListView(mYearAdapter,mYearListView,mYearListBeingTouched,mScrollStateOfYearView,mYearViewVisible);
      setListenersOnListView(mDateAdapter,mDateListView,mDateListBeingTouched,mScrollStateOfDayView,mDateViewVisible);
      getMiddlePosition();
    }
  }
);
}