Program: 33987
Project: 33987
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_scan);
  mHandler=new WeakHandler();
  setUpDefaultToolbar();
  scanProgressView=findViewById(R.id.scan_status_layout);
  scanResultListView=findViewById(R.id.scan_result_layout);
  scanResultNoCameraView=findViewById(R.id.scan_result_no_camera_layout);
  progressBar=(ProgressBar)findViewById(R.id.horizontal_progress_bar);
  progressBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.colorAccent),PorterDuff.Mode.SRC_IN);
  cameraListView=(ListView)findViewById(R.id.scan_result_list);
  Button addManuallyButton=(Button)findViewById(R.id.button_add_camera_manually);
  showAllDeviceButton=(Button)findViewById(R.id.button_show_all_devices);
  connectWifiButton=(Button)findViewById(R.id.button_connect_wifi);
  connectWifiButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
    }
  }
);
  View footerView=getLayoutInflater().inflate(R.layout.footer_scan_list,cameraListView,false);
  Button showAllDeviceFooterButton=(Button)footerView.findViewById(R.id.button_all_devices_in_list);
  cameraListView.addFooterView(footerView);
  deviceAdapter=new ScanResultAdapter(this,R.layout.item_scan_list,discoveredCameras,drawableArray);
  cameraListView.setAdapter(deviceAdapter);
  cameraListView.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> arg0,    View arg1,    int position,    long arg3){
      final DiscoveredCamera cameraInList=(DiscoveredCamera)cameraListView.getItemAtPosition(position);
      if (cameraInList != null) {
        if (isCameraAdded(cameraInList)) {
          CustomedDialog.getStandardAlertDialog(ScanActivity.this,new Dialog.OnClickListener(){
            @Override public void onClick(            DialogInterface dialog,            int which){
              launchAddCameraPage(cameraInList);
            }
          }
,R.string.msg_camera_has_been_added).show();
        }
 else {
          launchAddCameraPage(cameraInList);
        }
      }
    }
  }
);
  showAllDeviceFooterButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      AllDevicesActivity.showAllDevices(ScanActivity.this,nonCameraDevices);
    }
  }
);
  addManuallyButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivityForResult(new Intent(ScanActivity.this,AddEditCameraActivity.class),Constants.REQUEST_CODE_ADD_CAMERA);
    }
  }
);
  showAllDeviceButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      AllDevicesActivity.showAllDevices(ScanActivity.this,nonCameraDevices);
    }
  }
);
  new ScanCheckInternetTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_scan);
  mHandler=new WeakHandler();
  setUpDefaultToolbar();
  scanProgressView=findViewById(R.id.scan_status_layout);
  scanResultListView=findViewById(R.id.scan_result_layout);
  scanResultNoCameraView=findViewById(R.id.scan_result_no_camera_layout);
  progressBar=(ProgressBar)findViewById(R.id.horizontal_progress_bar);
  cameraListView=(ListView)findViewById(R.id.scan_result_list);
  Button addManuallyButton=(Button)findViewById(R.id.button_add_camera_manually);
  showAllDeviceButton=(Button)findViewById(R.id.button_show_all_devices);
  connectWifiButton=(Button)findViewById(R.id.button_connect_wifi);
  connectWifiButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
    }
  }
);
  View footerView=getLayoutInflater().inflate(R.layout.footer_scan_list,cameraListView,false);
  Button showAllDeviceFooterButton=(Button)footerView.findViewById(R.id.button_all_devices_in_list);
  cameraListView.addFooterView(footerView);
  deviceAdapter=new ScanResultAdapter(this,R.layout.item_scan_list,discoveredCameras,drawableArray);
  cameraListView.setAdapter(deviceAdapter);
  cameraListView.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> arg0,    View arg1,    int position,    long arg3){
      final DiscoveredCamera cameraInList=(DiscoveredCamera)cameraListView.getItemAtPosition(position);
      if (cameraInList != null) {
        if (isCameraAdded(cameraInList)) {
          CustomedDialog.getStandardAlertDialog(ScanActivity.this,new Dialog.OnClickListener(){
            @Override public void onClick(            DialogInterface dialog,            int which){
              launchAddCameraPage(cameraInList);
            }
          }
,R.string.msg_camera_has_been_added).show();
        }
 else {
          launchAddCameraPage(cameraInList);
        }
      }
    }
  }
);
  showAllDeviceFooterButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      AllDevicesActivity.showAllDevices(ScanActivity.this,nonCameraDevices);
    }
  }
);
  addManuallyButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      startActivityForResult(new Intent(ScanActivity.this,AddEditCameraActivity.class),Constants.REQUEST_CODE_ADD_CAMERA);
    }
  }
);
  showAllDeviceButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      AllDevicesActivity.showAllDevices(ScanActivity.this,nonCameraDevices);
    }
  }
);
  new ScanCheckInternetTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}