Program: 22541
Project: 22541
Buggy source:
@Override public void onViewCreated(final View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  chart=(LineChart)view.findViewById(R.id.data_chart);
  initializeChart();
  resetData(false);
  chart.invalidate();
  chart.setDescription(null);
  Button clearButton=(Button)view.findViewById(R.id.layout_two_button_left);
  clearButton.setOnClickListener(view1 -> refreshChart(true));
  clearButton.setText(R.string.label_clear);
  ((Switch)view.findViewById(R.id.sample_control)).setOnCheckedChangeListener((compoundButton,b) -> {
    if (b) {
      moveViewToLast();
      setup();
      chartHandler.postDelayed(updateChartTask,UPDATE_PERIOD);
    }
 else {
      chart.setVisibleXRangeMinimum(1);
      chart.setVisibleXRangeMaximum(sampleCount);
      clean();
      if (streamRoute != null) {
        streamRoute.remove();
        streamRoute=null;
      }
      chartHandler.removeCallbacks(updateChartTask);
    }
  }
);
  Button saveButton=(Button)view.findViewById(R.id.layout_two_button_right);
  saveButton.setText(R.string.label_save);
  saveButton.setOnClickListener(view12 -> {
    String filename=saveData();
    if (filename != null) {
      File dataFile=getActivity().getFileStreamPath(filename);
      Uri contentUri=FileProvider.getUriForFile(getActivity(),"String_Node_Str",dataFile);
      Intent intent=new Intent(Intent.ACTION_SEND);
      intent.setType("String_Node_Str");
      intent.putExtra(Intent.EXTRA_SUBJECT,filename);
      intent.putExtra(Intent.EXTRA_STREAM,contentUri);
      startActivity(Intent.createChooser(intent,"String_Node_Str"));
    }
  }
);
}

Fixed version (ground truth):
@Override public void onViewCreated(final View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  chart=(LineChart)view.findViewById(R.id.data_chart);
  initializeChart();
  resetData(false);
  chart.invalidate();
  chart.setDescription(null);
  Button clearButton=(Button)view.findViewById(R.id.layout_two_button_left);
  clearButton.setOnClickListener(view1 -> refreshChart(true));
  clearButton.setText(R.string.label_clear);
  ((Switch)view.findViewById(R.id.sample_control)).setOnCheckedChangeListener((compoundButton,b) -> {
    if (b) {
      moveViewToLast();
      setup();
    }
 else {
      chart.setVisibleXRangeMinimum(1);
      chart.setVisibleXRangeMaximum(sampleCount);
      clean();
      if (streamRoute != null) {
        streamRoute.remove();
        streamRoute=null;
      }
    }
  }
);
  Button saveButton=(Button)view.findViewById(R.id.layout_two_button_right);
  saveButton.setText(R.string.label_save);
  saveButton.setOnClickListener(view12 -> {
    String filename=saveData();
    if (filename != null) {
      File dataFile=getActivity().getFileStreamPath(filename);
      Uri contentUri=FileProvider.getUriForFile(getActivity(),"String_Node_Str",dataFile);
      Intent intent=new Intent(Intent.ACTION_SEND);
      intent.setType("String_Node_Str");
      intent.putExtra(Intent.EXTRA_SUBJECT,filename);
      intent.putExtra(Intent.EXTRA_STREAM,contentUri);
      startActivity(Intent.createChooser(intent,"String_Node_Str"));
    }
  }
);
}