Program: 35052
Project: 35052
Buggy source:
private void setupUnitTypePager(){
  FragmentManager fm=getSupportFragmentManager();
  mUnitTypeViewPager=(ViewPager)findViewById(R.id.convertKeyPager);
  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 unitTypePageIndicator=(TabPageIndicator)findViewById(R.id.titles);
  unitTypePageIndicator.setViewPager(mUnitTypeViewPager);
  unitTypePageIndicator.setVisibility(View.VISIBLE);
  unitTypePageIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      mCalc.setUnitTypePos(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());
}

Fixed version (ground truth):
private void setupUnitTypePager(){
  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 unitTypePageIndicator=(TabPageIndicator)findViewById(R.id.unit_type_titles);
  unitTypePageIndicator.setViewPager(mUnitTypeViewPager);
  unitTypePageIndicator.setVisibility(View.VISIBLE);
  unitTypePageIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      mCalc.setUnitTypePos(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());
}