Program: 35033
Project: 35033
Buggy source:
private void setupUnitTypePager(){
  if (mCalc.getUnitTypeSize() == 0) {
    setUnitViewVisibility(UnitVisibility.HIDDEN);
    return;
  }
 else {
    setUnitViewVisibility(UnitVisibility.VISIBLE);
  }
  FragmentManager fm=getSupportFragmentManager();
  mUnitTypeViewPager=(ViewPager)findViewById(R.id.unit_pager);
  mUnitTypeViewPager.setAdapter(new FragmentStatePagerAdapter(fm){
    @Override public int getCount(){
      return mCalc.getUnitTypeSize();
    }
    @Override public Fragment getItem(    int pos){
      return ConvKeysFragment.newInstance(pos);
    }
    @Override public CharSequence getPageTitle(    int pos){
      return mCalc.getUnitTypeName(pos % mCalc.getUnitTypeSize());
    }
  }
);
  TabPageIndicator mUnitTypeTabIndicator=(TabPageIndicator)findViewById(R.id.unit_type_titles);
  mUnitTypeTabIndicator.setViewPager(mUnitTypeViewPager);
  mUnitTypeTabIndicator.setVisibility(View.VISIBLE);
  mUnitTypeTabIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      mCalc.setCurrentUnitTypePos(pos);
      if (mCalc.getCurrUnitType().containsDynamicUnits())       mCalc.refreshAllDynamicUnits(false);
      int currUnitTypePos=mUnitTypeViewPager.getCurrentItem();
      clearUnitSelection(currUnitTypePos - 1);
      clearUnitSelection(currUnitTypePos);
      clearUnitSelection(currUnitTypePos + 1);
      mCalc.getCurrUnitType().clearUnitSelection();
      if (unitPosToSelectAfterScroll != -1) {
        ConvKeysFragment frag=getConvKeyFrag(mUnitTypeViewPager.getCurrentItem());
        if (frag != null)         frag.selectUnitAtUnitArrayPos(unitPosToSelectAfterScroll);
        unitPosToSelectAfterScroll=-1;
      }
      updateScreen(false);
      mDisplay.setSelectionToEnd();
    }
    @Override public void onPageScrolled(    int pos,    float posOffset,    int posOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  mUnitTypeViewPager.setCurrentItem(mCalc.getUnitTypePos());
  mUnitTypeTabIndicator.notifyDataSetChanged();
}

Fixed version (ground truth):
private void setupUnitTypePager(){
  if (mCalc.getUnitTypeSize() == 0) {
    setUnitViewVisibility(UnitVisibility.HIDDEN);
    return;
  }
 else {
    setUnitViewVisibility(UnitVisibility.VISIBLE);
  }
  FragmentManager fm=getSupportFragmentManager();
  mUnitTypeViewPager=(ViewPager)findViewById(R.id.unit_pager);
  mUnitTypeViewPager.setAdapter(new FragmentStatePagerAdapter(fm){
    @Override public int getCount(){
      return mCalc.getUnitTypeSize();
    }
    @Override public Fragment getItem(    int pos){
      return ConvKeysFragment.newInstance(pos);
    }
    @Override public CharSequence getPageTitle(    int pos){
      return mCalc.getUnitTypeName(pos % mCalc.getUnitTypeSize());
    }
  }
);
  TabPageIndicator mUnitTypeTabIndicator=(TabPageIndicator)findViewById(R.id.unit_type_titles);
  mUnitTypeTabIndicator.setViewPager(mUnitTypeViewPager);
  mUnitTypeTabIndicator.setVisibility(View.VISIBLE);
  mUnitTypeTabIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      mCalc.getCurrUnitType().clearUnitSelection();
      mCalc.setCurrentUnitTypePos(pos);
      if (mCalc.getCurrUnitType().containsDynamicUnits())       mCalc.refreshAllDynamicUnits(false);
      int currUnitTypePos=mUnitTypeViewPager.getCurrentItem();
      clearUnitSelection(currUnitTypePos - 1);
      clearUnitSelection(currUnitTypePos);
      clearUnitSelection(currUnitTypePos + 1);
      mCalc.getCurrUnitType().clearUnitSelection();
      if (unitPosToSelectAfterScroll != -1) {
        ConvKeysFragment frag=getConvKeyFrag(mUnitTypeViewPager.getCurrentItem());
        if (frag != null)         frag.selectUnitAtUnitArrayPos(unitPosToSelectAfterScroll);
        unitPosToSelectAfterScroll=-1;
      }
      updateScreen(false);
      mDisplay.setSelectionToEnd();
    }
    @Override public void onPageScrolled(    int pos,    float posOffset,    int posOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  mUnitTypeViewPager.setCurrentItem(mCalc.getUnitTypePos());
  mUnitTypeTabIndicator.notifyDataSetChanged();
}