Program: 146473
Project: 146473
Buggy source:
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  ViewGroup viewGroup;
  if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    viewGroup=(ViewGroup)buttonView.getParent().getParent().getParent();
  }
 else {
    viewGroup=(ViewGroup)buttonView.getParent();
  }
  StockChartView stockChartView=(StockChartView)viewGroup.findViewById(R.id.StockChartView);
  IndicatorManager iManager=stockChartView.getIndicatorManager();
  if (stockChartView.findSeriesByName("String_Node_Str") != null) {
    if (isChecked) {
switch (buttonView.getId()) {
case R.id.enableEMAIndicator:
        iManager.addEma(stockChartView.findSeriesByName("String_Node_Str"),0);
      break;
case R.id.enableMACDIndicator:
    iManager.addMacd(stockChartView.findSeriesByName("String_Node_Str"),0);
  break;
case R.id.enableRSIIndicator:
iManager.addRsi(stockChartView.findSeriesByName("String_Node_Str"),0);
break;
case R.id.enableSMAIndicator:
iManager.addSma(stockChartView.findSeriesByName("String_Node_Str"),0);
break;
default :
break;
}
stockChartView.recalcIndicators();
stockChartView.recalc();
stockChartView.invalidate();
}
 else {
List<AbstractIndicator> indicators=stockChartView.getIndicatorManager().getIndicators();
for (AbstractIndicator x : indicators) {
switch (buttonView.getId()) {
case R.id.enableEMAIndicator:
if (x instanceof EmaIndicator) {
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
case R.id.enableMACDIndicator:
if (x instanceof MacdIndicator) {
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
case R.id.enableRSIIndicator:
if (x instanceof RsiIndicator) {
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
case R.id.enableSMAIndicator:
if (x instanceof SmaIndicator) {
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
default :
break;
}
}
stockChartView.recalc();
stockChartView.invalidate();
}
}
 else {
SwitchCompat sw=(SwitchCompat)buttonView;
sw.setChecked(!isChecked);
}
}

Fixed version (ground truth):
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  ViewGroup viewGroup;
  if (getResources().getConfiguration().screenWidthDp >= 350) {
    viewGroup=(ViewGroup)buttonView.getParent().getParent().getParent();
  }
 else {
    viewGroup=(ViewGroup)buttonView.getParent();
  }
  StockChartView stockChartView=(StockChartView)viewGroup.findViewById(R.id.stockChartView);
  IndicatorManager iManager=stockChartView.getIndicatorManager();
  if (stockChartView.findSeriesByName("String_Node_Str") != null) {
    if (isChecked) {
switch (buttonView.getId()) {
case R.id.enableEMAIndicator:
        iManager.addEma(stockChartView.findSeriesByName("String_Node_Str"),0);
      break;
case R.id.enableMACDIndicator:
    iManager.addMacd(stockChartView.findSeriesByName("String_Node_Str"),0);
  break;
case R.id.enableRSIIndicator:
iManager.addRsi(stockChartView.findSeriesByName("String_Node_Str"),0);
break;
case R.id.enableSMAIndicator:
iManager.addSma(stockChartView.findSeriesByName("String_Node_Str"),0);
break;
default :
break;
}
stockChartView.recalcIndicators();
stockChartView.recalc();
stockChartView.invalidate();
}
 else {
Iterator<AbstractIndicator> iterator=stockChartView.getIndicatorManager().getIndicators().iterator();
while (iterator.hasNext()) {
AbstractIndicator x=iterator.next();
switch (buttonView.getId()) {
case R.id.enableEMAIndicator:
if (x instanceof EmaIndicator) {
iterator.remove();
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
case R.id.enableMACDIndicator:
if (x instanceof MacdIndicator) {
iterator.remove();
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
case R.id.enableRSIIndicator:
if (x instanceof RsiIndicator) {
iterator.remove();
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
case R.id.enableSMAIndicator:
if (x instanceof SmaIndicator) {
iterator.remove();
stockChartView.getIndicatorManager().removeIndicator(x);
}
break;
default :
break;
}
}
stockChartView.recalc();
stockChartView.invalidate();
}
}
 else {
SwitchCompat sw=(SwitchCompat)buttonView;
sw.setChecked(!isChecked);
}
}