Program: 34012
Project: 34012
Buggy source:
private void initialScreen(){
  FragmentManager fragmentManager=getSupportFragmentManager();
  modelSelectorFragment=(ModelSelectorFragment)fragmentManager.findFragmentById(R.id.model_selector_fragment);
  cameraIdLayout=(LinearLayout)findViewById(R.id.add_camera_id_layout);
  cameraIdTextView=(TextView)findViewById(R.id.add_id_txt_view);
  cameraNameEdit=(EditText)findViewById(R.id.add_name_edit);
  ImageView externalIpExplainationImageButton=(ImageView)findViewById(R.id.ip_explanation_btn);
  ImageView httpExplainationImageButton=(ImageView)findViewById(R.id.http_explanation_btn);
  ImageView jpgExplainationImageButton=(ImageView)findViewById(R.id.jpg_explanation_btn);
  ImageView rtspPortExplainationImageButton=(ImageView)findViewById(R.id.rtsp_port_explanation_btn);
  ImageView rtspUrlExplainationImageButton=(ImageView)findViewById(R.id.rtsp_url_explanation_btn);
  usernameEdit=(EditText)findViewById(R.id.add_username_edit);
  passwordEdit=(EditText)findViewById(R.id.add_password_edit);
  externalHostEdit=(PortCheckEditText)findViewById(R.id.add_external_host_edit);
  externalHttpEdit=(PortCheckEditText)findViewById(R.id.add_external_http_edit);
  externalRtspEdit=(PortCheckEditText)findViewById(R.id.add_external_rtsp_edit);
  jpgUrlEdit=(EditText)findViewById(R.id.add_jpg_edit);
  rtspUrlEdit=(EditText)findViewById(R.id.add_rtsp_edit);
  mHttpStatusTextView=(TextView)findViewById(R.id.port_status_text_http);
  mRtspStatusTextView=(TextView)findViewById(R.id.port_status_text_rtsp);
  mHttpProgressBar=(ProgressBar)findViewById(R.id.progress_bar_http);
  mRtspProgressBar=(ProgressBar)findViewById(R.id.progress_bar_rtsp);
  jpgUrlLayout=(LinearLayout)findViewById(R.id.add_jpg_url_layout);
  rtspUrlLayout=(LinearLayout)findViewById(R.id.add_rtsp_url_layout);
  addEditButton=(Button)findViewById(R.id.button_add_edit_camera);
  Button testButton=(Button)findViewById(R.id.button_test_snapshot);
  mValidateHostInput=new ValidateHostInput(externalHostEdit,externalHttpEdit,externalRtspEdit){
    @Override public void onHostEmpty(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.host_required));
    }
    @Override public void onHttpEmpty(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.external_http_required));
    }
    @Override public void onInvalidHttpPort(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.msg_port_range_error));
    }
    @Override public void onInvalidRtspPort(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.msg_port_range_error));
    }
  }
;
  if (cameraEdit != null) {
    addEditButton.setText(getString(R.string.save_changes));
    cameraIdLayout.setVisibility(View.VISIBLE);
  }
 else {
    cameraIdLayout.setVisibility(View.GONE);
    addEditButton.setText(getString(R.string.finish_and_add));
  }
  externalIpExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_ip_explanation_title,R.string.msg_ip_explanation);
    }
  }
);
  jpgExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_jpg_explanation_title,R.string.msg_jpg_explanation);
    }
  }
);
  httpExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_http_explanation_title,R.string.msg_http_explanation);
    }
  }
);
  rtspPortExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_rtsp_port_explanation_title,R.string.msg_rtsp_port_explanation);
    }
  }
);
  rtspUrlExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_rtsp_url_explanation_title,R.string.msg_rtsp_url_explanation);
    }
  }
);
  externalHttpEdit.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View view,    boolean hasFocus){
      if (hasFocus) {
        externalHttpEdit.hideStatusViewsOnTextChange(mHttpStatusTextView);
      }
 else {
        checkPort(PortCheckTask.PortType.HTTP);
      }
    }
  }
);
  externalRtspEdit.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View v,    boolean hasFocus){
      if (hasFocus) {
        externalRtspEdit.hideStatusViewsOnTextChange(mRtspStatusTextView);
      }
 else {
        checkPort(PortCheckTask.PortType.RTSP);
      }
    }
  }
);
  externalHostEdit.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View v,    boolean hasFocus){
      if (hasFocus) {
        externalHostEdit.hideStatusViewsOnTextChange(mRtspStatusTextView,mHttpStatusTextView);
      }
 else {
        checkPort(PortCheckTask.PortType.HTTP);
        checkPort(PortCheckTask.PortType.RTSP);
      }
    }
  }
);
  jpgUrlEdit.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!jpgUrlEdit.isFocusable()) {
        CustomedDialog.getMessageDialog(AddEditCameraActivity.this,R.string.msg_url_ending_not_editable).show();
      }
    }
  }
);
  addEditButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      String externalHost=externalHostEdit.getText().toString();
      if (Commons.isLocalIp(externalHost)) {
        CustomedDialog.getStandardAlertDialog(AddEditCameraActivity.this,new DialogInterface.OnClickListener(){
          @Override public void onClick(          DialogInterface dialog,          int which){
            performAddEdit();
          }
        }
,R.string.msg_local_ip_warning).show();
      }
 else {
        performAddEdit();
      }
    }
  }
);
  testButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      String externalHost=externalHostEdit.getText().toString();
      if (Commons.isLocalIp(externalHost)) {
        CustomedDialog.getStandardAlertDialog(AddEditCameraActivity.this,new DialogInterface.OnClickListener(){
          @Override public void onClick(          DialogInterface dialog,          int which){
            launchTestSnapshot();
          }
        }
,R.string.msg_local_ip_warning).show();
      }
 else {
        launchTestSnapshot();
      }
    }
  }
);
}

Fixed version (ground truth):
private void initialScreen(){
  FragmentManager fragmentManager=getSupportFragmentManager();
  modelSelectorFragment=(ModelSelectorFragment)fragmentManager.findFragmentById(R.id.model_selector_fragment);
  cameraIdLayout=(LinearLayout)findViewById(R.id.add_camera_id_layout);
  cameraIdTextView=(TextView)findViewById(R.id.add_id_txt_view);
  cameraNameEdit=(EditText)findViewById(R.id.add_name_edit);
  ImageView externalIpExplainationImageButton=(ImageView)findViewById(R.id.ip_explanation_btn);
  ImageView httpExplainationImageButton=(ImageView)findViewById(R.id.http_explanation_btn);
  ImageView jpgExplainationImageButton=(ImageView)findViewById(R.id.jpg_explanation_btn);
  ImageView rtspPortExplainationImageButton=(ImageView)findViewById(R.id.rtsp_port_explanation_btn);
  ImageView rtspUrlExplainationImageButton=(ImageView)findViewById(R.id.rtsp_url_explanation_btn);
  usernameEdit=(EditText)findViewById(R.id.add_username_edit);
  passwordEdit=(EditText)findViewById(R.id.add_password_edit);
  externalHostEdit=(PortCheckEditText)findViewById(R.id.add_external_host_edit);
  externalHttpEdit=(PortCheckEditText)findViewById(R.id.add_external_http_edit);
  externalRtspEdit=(PortCheckEditText)findViewById(R.id.add_external_rtsp_edit);
  jpgUrlEdit=(EditText)findViewById(R.id.add_jpg_edit);
  rtspUrlEdit=(EditText)findViewById(R.id.add_rtsp_edit);
  mHttpStatusTextView=(TextView)findViewById(R.id.port_status_text_http);
  mRtspStatusTextView=(TextView)findViewById(R.id.port_status_text_rtsp);
  mHttpProgressBar=(ProgressBar)findViewById(R.id.progress_bar_http);
  mRtspProgressBar=(ProgressBar)findViewById(R.id.progress_bar_rtsp);
  jpgUrlLayout=(LinearLayout)findViewById(R.id.add_jpg_url_layout);
  rtspUrlLayout=(LinearLayout)findViewById(R.id.add_rtsp_url_layout);
  addEditButton=(Button)findViewById(R.id.button_add_edit_camera);
  Button testButton=(Button)findViewById(R.id.button_test_snapshot);
  mValidateHostInput=new ValidateHostInput(externalHostEdit,externalHttpEdit,externalRtspEdit){
    @Override public void onLocalIp(){
      externalHostEdit.requestFocus();
      showLocalIpWarning();
    }
    @Override public void onHostEmpty(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.host_required));
    }
    @Override public void onHttpEmpty(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.external_http_required));
    }
    @Override public void onInvalidHttpPort(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.msg_port_range_error));
    }
    @Override public void onInvalidRtspPort(){
      CustomToast.showInCenter(AddEditCameraActivity.this,getString(R.string.msg_port_range_error));
    }
  }
;
  if (cameraEdit != null) {
    addEditButton.setText(getString(R.string.save_changes));
    cameraIdLayout.setVisibility(View.VISIBLE);
  }
 else {
    cameraIdLayout.setVisibility(View.GONE);
    addEditButton.setText(getString(R.string.finish_and_add));
  }
  externalIpExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_ip_explanation_title,R.string.msg_ip_explanation);
    }
  }
);
  jpgExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_jpg_explanation_title,R.string.msg_jpg_explanation);
    }
  }
);
  httpExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_http_explanation_title,R.string.msg_http_explanation);
    }
  }
);
  rtspPortExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_rtsp_port_explanation_title,R.string.msg_rtsp_port_explanation);
    }
  }
);
  rtspUrlExplainationImageButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      CustomedDialog.showMessageDialogWithTitle(AddEditCameraActivity.this,R.string.msg_rtsp_url_explanation_title,R.string.msg_rtsp_url_explanation);
    }
  }
);
  externalHttpEdit.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View view,    boolean hasFocus){
      if (hasFocus) {
        externalHttpEdit.hideStatusViewsOnTextChange(mHttpStatusTextView);
      }
 else {
        checkPort(PortCheckTask.PortType.HTTP);
      }
    }
  }
);
  externalRtspEdit.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View v,    boolean hasFocus){
      if (hasFocus) {
        externalRtspEdit.hideStatusViewsOnTextChange(mRtspStatusTextView);
      }
 else {
        checkPort(PortCheckTask.PortType.RTSP);
      }
    }
  }
);
  externalHostEdit.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View v,    boolean hasFocus){
      if (hasFocus) {
        externalHostEdit.hideStatusViewsOnTextChange(mRtspStatusTextView,mHttpStatusTextView);
      }
 else {
        checkPort(PortCheckTask.PortType.HTTP);
        checkPort(PortCheckTask.PortType.RTSP);
      }
    }
  }
);
  jpgUrlEdit.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!jpgUrlEdit.isFocusable()) {
        CustomedDialog.getMessageDialog(AddEditCameraActivity.this,R.string.msg_url_ending_not_editable).show();
      }
    }
  }
);
  addEditButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      String externalHost=externalHostEdit.getText().toString();
      if (Commons.isLocalIp(externalHost)) {
        showLocalIpWarning();
      }
 else {
        performAddEdit();
      }
    }
  }
);
  testButton.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      String externalHost=externalHostEdit.getText().toString();
      if (Commons.isLocalIp(externalHost)) {
        showLocalIpWarning();
      }
 else {
        launchTestSnapshot();
      }
    }
  }
);
}