Program: 35118
Project: 35118
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_calc);
  calc=Calculator.getCalculator(this);
  mDisplay=(EditTextCursorWatcher)findViewById(R.id.textDisplay);
  mDisplay.setCalc(calc);
  mDisplay.disableSoftInputFromAppearing();
  FragmentManager fm=getSupportFragmentManager();
  Fragment resultFragment=fm.findFragmentById(R.id.resultListfragmentContainer);
  if (resultFragment == null) {
    resultFragment=new ResultListFragment();
    fm.beginTransaction().add(R.id.resultListfragmentContainer,resultFragment).commit();
  }
  mViewPager=(ViewPager)findViewById(R.id.convertKeyPager);
  mViewPager.setAdapter(new FragmentStatePagerAdapter(fm){
    @Override public int getCount(){
      return calc.getUnitTypeSize();
    }
    @Override public Fragment getItem(    int pos){
      return ConvertKeysFragment.newInstance(pos);
    }
  }
);
  mViewPager.setPageMargin(10);
  mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      calc.getCurrUnitType().clearUnitSelection();
      updateScreen(false);
      calc.setUnitTypePos(pos);
    }
    @Override public void onPageScrolled(    int pos,    float posOffset,    int posOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  calcButton=new ArrayList<Button>();
  for (  int id : BUTTON_IDS) {
    Button button=(Button)findViewById(id);
    button.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View view){
        int buttonId=view.getId();
        String buttonValue="String_Node_Str";
switch (buttonId) {
case R.id.plus_button:
          buttonValue="String_Node_Str";
        break;
case R.id.minus_button:
      buttonValue="String_Node_Str";
    break;
case R.id.multiply_button:
  buttonValue="String_Node_Str";
break;
case R.id.divide_button:
buttonValue="String_Node_Str";
break;
case R.id.decimal_button:
buttonValue="String_Node_Str";
break;
case R.id.equals_button:
buttonValue="String_Node_Str";
break;
case R.id.ee_button:
buttonValue="String_Node_Str";
break;
case R.id.power_button:
buttonValue="String_Node_Str";
break;
case R.id.open_para_button:
buttonValue="String_Node_Str";
break;
case R.id.close_para_button:
buttonValue="String_Node_Str";
break;
case R.id.backspace_button:
buttonValue="String_Node_Str";
break;
default :
for (int i=0; i < 10; i++) if (buttonId == BUTTON_IDS[i]) buttonValue=String.valueOf(i);
}
numButtonPressed(buttonValue);
}
}
);
calcButton.add(button);
}
ImageButton backspaceButton=(ImageButton)findViewById(R.id.backspace_button);
backspaceButton.setOnTouchListener(new View.OnTouchListener(){
private Handler mHandler;
@Override public boolean onTouch(View view,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (mHandler != null) return true;
mHandler=new Handler();
mHandler.postDelayed(mBackspaceRepeat,400);
numButtonPressed("String_Node_Str");
break;
case MotionEvent.ACTION_UP:
if (mHandler == null) return true;
mHandler.removeCallbacks(mBackspaceRepeat);
mHandler=null;
break;
}
return false;
}
Runnable mBackspaceRepeat=new Runnable(){
@Override public void run(){
mHandler.postDelayed(this,100);
numButtonPressed("String_Node_Str");
}
}
;
}
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_calc);
  mCalc=Calculator.getCalculator(this);
  mDisplay=(EditTextCursorWatcher)findViewById(R.id.textDisplay);
  mDisplay.setCalc(mCalc);
  mDisplay.disableSoftInputFromAppearing();
  FragmentManager fm=getSupportFragmentManager();
  Fragment resultFragment=fm.findFragmentById(R.id.resultListfragmentContainer);
  if (resultFragment == null) {
    resultFragment=new ResultListFragment();
    fm.beginTransaction().add(R.id.resultListfragmentContainer,resultFragment).commit();
  }
  mViewPager=(ViewPager)findViewById(R.id.convertKeyPager);
  mViewPager.setAdapter(new FragmentStatePagerAdapter(fm){
    @Override public int getCount(){
      return mCalc.getUnitTypeSize();
    }
    @Override public Fragment getItem(    int pos){
      return ConvertKeysFragment.newInstance(pos);
    }
  }
);
  mViewPager.setPageMargin(10);
  mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      mCalc.getCurrUnitType().clearUnitSelection();
      updateScreen(false);
      mCalc.setUnitTypePos(pos);
    }
    @Override public void onPageScrolled(    int pos,    float posOffset,    int posOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  calcButton=new ArrayList<Button>();
  for (  int id : BUTTON_IDS) {
    Button button=(Button)findViewById(id);
    button.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View view){
        int buttonId=view.getId();
        String buttonValue="String_Node_Str";
switch (buttonId) {
case R.id.plus_button:
          buttonValue="String_Node_Str";
        break;
case R.id.minus_button:
      buttonValue="String_Node_Str";
    break;
case R.id.multiply_button:
  buttonValue="String_Node_Str";
break;
case R.id.divide_button:
buttonValue="String_Node_Str";
break;
case R.id.decimal_button:
buttonValue="String_Node_Str";
break;
case R.id.equals_button:
buttonValue="String_Node_Str";
break;
case R.id.ee_button:
buttonValue="String_Node_Str";
break;
case R.id.power_button:
buttonValue="String_Node_Str";
break;
case R.id.open_para_button:
buttonValue="String_Node_Str";
break;
case R.id.close_para_button:
buttonValue="String_Node_Str";
break;
case R.id.backspace_button:
buttonValue="String_Node_Str";
break;
default :
for (int i=0; i < 10; i++) if (buttonId == BUTTON_IDS[i]) buttonValue=String.valueOf(i);
}
numButtonPressed(buttonValue);
}
}
);
calcButton.add(button);
}
ImageButton backspaceButton=(ImageButton)findViewById(R.id.backspace_button);
backspaceButton.setOnTouchListener(new View.OnTouchListener(){
private Handler mHandler;
@Override public boolean onTouch(View view,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (mHandler != null) return true;
mHandler=new Handler();
mHandler.postDelayed(mBackspaceRepeat,400);
numButtonPressed("String_Node_Str");
break;
case MotionEvent.ACTION_UP:
if (mHandler == null) return true;
mHandler.removeCallbacks(mBackspaceRepeat);
mHandler=null;
break;
}
return false;
}
Runnable mBackspaceRepeat=new Runnable(){
@Override public void run(){
mHandler.postDelayed(this,100);
numButtonPressed("String_Node_Str");
}
}
;
}
);
}