Program: 34117
Project: 34117
Buggy source:
public boolean addAllCameraViews(boolean reloadImages){
  try {
    SharedPreferences sharedPrefs=PreferenceManager.getDefaultSharedPreferences(this);
    camerasPerRow=PrefsManager.getCameraPerRow(sharedPrefs,camerasPerRow);
    io.evercam.androidapp.custom.FlowLayout camsLineView=(io.evercam.androidapp.custom.FlowLayout)this.findViewById(R.id.camsLV);
    int screen_width=readScreenWidth(this);
    int index=0;
    totalCamerasInGrid=0;
    for (    EvercamCamera evercamCamera : AppData.evercamCameraList) {
      LinearLayout cameraListLayout=new LinearLayout(this);
      int indexPlus=index + 1;
      if (reloadImages)       evercamCamera.loadingStatus=ImageLoadingStatus.not_started;
      CameraLayout cameraLayout=new CameraLayout(this,evercamCamera);
      LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
      params.width=((indexPlus % camerasPerRow == 0) ? (screen_width - (index % camerasPerRow) * (screen_width / camerasPerRow)) : screen_width / camerasPerRow);
      params.height=(int)(params.width / (1.25));
      cameraLayout.setLayoutParams(params);
      cameraListLayout.addView(cameraLayout);
      camsLineView.addView(cameraListLayout,new io.evercam.androidapp.custom.FlowLayout.LayoutParams(0,0));
      index++;
      totalCamerasInGrid++;
    }
    if (this.getActionBar() != null)     this.getActionBar().setHomeButtonEnabled(true);
    if (refresh != null)     refresh.setActionView(null);
    return true;
  }
 catch (  Exception e) {
    Log.e(TAG,e.toString(),e);
    if (Constants.isAppTrackingEnabled) {
      BugSenseHandler.sendException(e);
    }
    EvercamPlayApplication.sendEventAnalytics(this,R.string.category_error,R.string.action_error_camera_list,R.string.label_error_add_cameras);
    EvercamPlayApplication.sendCaughtException(this,e);
    CustomedDialog.showUnexpectedErrorDialog(CamerasActivity.this);
  }
  return false;
}

Fixed version (ground truth):
public boolean addAllCameraViews(boolean reloadImages){
  try {
    camerasPerRow=recalculateCameraPerRow();
    io.evercam.androidapp.custom.FlowLayout camsLineView=(io.evercam.androidapp.custom.FlowLayout)this.findViewById(R.id.camsLV);
    int screen_width=readScreenWidth(this);
    int index=0;
    totalCamerasInGrid=0;
    for (    EvercamCamera evercamCamera : AppData.evercamCameraList) {
      LinearLayout cameraListLayout=new LinearLayout(this);
      int indexPlus=index + 1;
      if (reloadImages)       evercamCamera.loadingStatus=ImageLoadingStatus.not_started;
      CameraLayout cameraLayout=new CameraLayout(this,evercamCamera);
      LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
      params.width=((indexPlus % camerasPerRow == 0) ? (screen_width - (index % camerasPerRow) * (screen_width / camerasPerRow)) : screen_width / camerasPerRow);
      params.height=(int)(params.width / (1.25));
      cameraLayout.setLayoutParams(params);
      cameraListLayout.addView(cameraLayout);
      camsLineView.addView(cameraListLayout,new io.evercam.androidapp.custom.FlowLayout.LayoutParams(0,0));
      index++;
      totalCamerasInGrid++;
    }
    if (this.getActionBar() != null)     this.getActionBar().setHomeButtonEnabled(true);
    if (refresh != null)     refresh.setActionView(null);
    return true;
  }
 catch (  Exception e) {
    Log.e(TAG,e.toString(),e);
    if (Constants.isAppTrackingEnabled) {
      BugSenseHandler.sendException(e);
    }
    EvercamPlayApplication.sendEventAnalytics(this,R.string.category_error,R.string.action_error_camera_list,R.string.label_error_add_cameras);
    EvercamPlayApplication.sendCaughtException(this,e);
    CustomedDialog.showUnexpectedErrorDialog(CamerasActivity.this);
  }
  return false;
}