Program: 35116
Project: 35116
Buggy source:
@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();
  mResultFragment=(ResultListFragment)fm.findFragmentById(R.id.resultListfragmentContainer);
  if (mResultFragment == null) {
    mResultFragment=new ResultListFragment();
    fm.beginTransaction().add(R.id.resultListfragmentContainer,mResultFragment).commit();
  }
  mViewPager=(ViewPager)findViewById(R.id.convertKeyPager);
  mViewPager.setAdapter(new FragmentStatePagerAdapter(fm){
    @Override public int getCount(){
      return 10000;
    }
    @Override public Fragment getItem(    int pos){
      System.out.println("String_Node_Str" + pos);
      System.out.println("String_Node_Str" + pos % mCalc.getUnitTypeSize());
      return ConvertKeysFragment.newInstance(pos % mCalc.getUnitTypeSize());
    }
  }
);
  mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      mCalc.getCurrUnitType().clearUnitSelection();
      updateScreen(false);
      mCalc.setUnitTypePos(pos);
      DisplayMetrics metrics=getResources().getDisplayMetrics();
      int padLeft=(int)(metrics.density * 8f + 0.5f);
      int padRight=(int)(metrics.density * 8f + 0.5f);
      mViewPager.setPadding(padLeft,0,padRight,0);
    }
    @Override public void onPageScrolled(    int pos,    float posOffset,    int posOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  DisplayMetrics metrics=getResources().getDisplayMetrics();
  int padLeft=(int)(metrics.density * 8f + 0.5f);
  int padRight=padLeft;
  mViewPager.setPadding(padLeft,0,padRight,0);
  mViewPager.setClipToPadding(false);
  mViewPager.setPageMargin(8);
  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 mColorHoldHandler;
private View mView;
@Override public boolean onTouch(View view,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mView=view;
mInc=0;
if (mColorHoldHandler != null) return true;
mColorHoldHandler=new Handler();
mColorHoldHandler.postDelayed(mBackspaceColor,10);
break;
case MotionEvent.ACTION_UP:
if (mColorHoldHandler == null) return true;
numButtonPressed("String_Node_Str");
view.setBackgroundColor(getResources().getColor(R.color.op_button_normal));
mColorHoldHandler.removeCallbacks(mBackspaceColor);
mColorHoldHandler=null;
break;
}
return false;
}
private int mInc;
Runnable mBackspaceColor=new Runnable(){
private int mStartColor=getResources().getColor(R.color.op_button_pressed);
private int mEndColor=getResources().getColor(R.color.backspace_button_held);
private static final int NUM_COLOR_CHANGES=10;
private static final int BACKSPACE_HOLD_TIME=500;
@Override public void run(){
if (mInc == -1) {
mView.setBackgroundColor(mEndColor);
return;
}
if (mInc == NUM_COLOR_CHANGES) {
numButtonPressed("String_Node_Str");
mView.setBackgroundColor(Color.argb(255,0,0,0));
mColorHoldHandler.postDelayed(this,100);
mInc=-1;
return;
}
mColorHoldHandler.postDelayed(this,BACKSPACE_HOLD_TIME / NUM_COLOR_CHANGES);
float deltaRed=(float)Color.red(mStartColor) + ((float)Color.red(mEndColor) - (float)Color.red(mStartColor)) * ((float)mInc * (float)mInc * (float)mInc) / ((float)NUM_COLOR_CHANGES * (float)NUM_COLOR_CHANGES * (float)NUM_COLOR_CHANGES);
int deltaGreen=Color.green(mStartColor) + ((Color.green(mEndColor) - Color.green(mStartColor)) * mInc) / NUM_COLOR_CHANGES;
int deltaBlue=Color.blue(mStartColor) + ((Color.blue(mEndColor) - Color.blue(mStartColor)) * mInc) / NUM_COLOR_CHANGES;
mView.setBackgroundColor(Color.argb(255,(int)deltaRed,deltaGreen,deltaBlue));
System.out.println("String_Node_Str" + deltaRed);
System.out.println("String_Node_Str" + ((Color.red(mEndColor) - Color.red(mStartColor)) * mInc ^ 3));
System.out.println("String_Node_Str" + mInc);
mInc++;
}
}
;
}
);
}

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();
  mDisplay.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      mCalc.setSolved(false);
      mDisplay.setCursorVisible(true);
    }
  }
);
  FragmentManager fm=getSupportFragmentManager();
  mResultFragment=(ResultListFragment)fm.findFragmentById(R.id.resultListfragmentContainer);
  if (mResultFragment == null) {
    mResultFragment=new ResultListFragment();
    fm.beginTransaction().add(R.id.resultListfragmentContainer,mResultFragment).commit();
  }
  mViewPager=(ViewPager)findViewById(R.id.convertKeyPager);
  mViewPager.setAdapter(new FragmentStatePagerAdapter(fm){
    @Override public int getCount(){
      return 10000;
    }
    @Override public Fragment getItem(    int pos){
      System.out.println("String_Node_Str" + pos);
      System.out.println("String_Node_Str" + pos % mCalc.getUnitTypeSize());
      return ConvertKeysFragment.newInstance(pos % mCalc.getUnitTypeSize());
    }
  }
);
  mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int pos){
      mCalc.getCurrUnitType().clearUnitSelection();
      updateScreen(false);
      mCalc.setUnitTypePos(pos);
      DisplayMetrics metrics=getResources().getDisplayMetrics();
      int padLeft=(int)(metrics.density * 8f + 0.5f);
      int padRight=(int)(metrics.density * 8f + 0.5f);
      mViewPager.setPadding(padLeft,0,padRight,0);
    }
    @Override public void onPageScrolled(    int pos,    float posOffset,    int posOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  DisplayMetrics metrics=getResources().getDisplayMetrics();
  int padLeft=(int)(metrics.density * 8f + 0.5f);
  int padRight=padLeft;
  mViewPager.setPadding(padLeft,0,padRight,0);
  mViewPager.setClipToPadding(false);
  mViewPager.setPageMargin(8);
  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 mColorHoldHandler;
private View mView;
@Override public boolean onTouch(View view,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mView=view;
mInc=0;
if (mColorHoldHandler != null) return true;
mColorHoldHandler=new Handler();
mColorHoldHandler.postDelayed(mBackspaceColor,10);
break;
case MotionEvent.ACTION_UP:
if (mColorHoldHandler == null) return true;
numButtonPressed("String_Node_Str");
view.setBackgroundColor(getResources().getColor(R.color.op_button_normal));
mColorHoldHandler.removeCallbacks(mBackspaceColor);
mColorHoldHandler=null;
break;
}
return false;
}
private int mInc;
Runnable mBackspaceColor=new Runnable(){
private int mStartColor=getResources().getColor(R.color.op_button_pressed);
private int mEndColor=getResources().getColor(R.color.backspace_button_held);
private static final int NUM_COLOR_CHANGES=10;
private static final int BACKSPACE_HOLD_TIME=500;
@Override public void run(){
if (mInc == -1) {
mView.setBackgroundColor(mEndColor);
return;
}
if (mInc == NUM_COLOR_CHANGES) {
numButtonPressed("String_Node_Str");
mView.setBackgroundColor(Color.argb(255,0,0,0));
mColorHoldHandler.postDelayed(this,100);
mInc=-1;
return;
}
mColorHoldHandler.postDelayed(this,BACKSPACE_HOLD_TIME / NUM_COLOR_CHANGES);
float deltaRed=(float)Color.red(mStartColor) + ((float)Color.red(mEndColor) - (float)Color.red(mStartColor)) * ((float)mInc * (float)mInc * (float)mInc) / ((float)NUM_COLOR_CHANGES * (float)NUM_COLOR_CHANGES * (float)NUM_COLOR_CHANGES);
int deltaGreen=Color.green(mStartColor) + ((Color.green(mEndColor) - Color.green(mStartColor)) * mInc) / NUM_COLOR_CHANGES;
int deltaBlue=Color.blue(mStartColor) + ((Color.blue(mEndColor) - Color.blue(mStartColor)) * mInc) / NUM_COLOR_CHANGES;
mView.setBackgroundColor(Color.argb(255,(int)deltaRed,deltaGreen,deltaBlue));
System.out.println("String_Node_Str" + deltaRed);
System.out.println("String_Node_Str" + ((Color.red(mEndColor) - Color.red(mStartColor)) * mInc ^ 3));
System.out.println("String_Node_Str" + mInc);
mInc++;
}
}
;
}
);
}