Program: 34139
Project: 34139
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (Constants.isAppTrackingEnabled) {
    BugSenseHandler.initAndStartSession(this,Constants.bugsense_ApiKey);
  }
  EvercamPlayApplication.sendScreenAnalytics(this,getString(R.string.screen_manage_account));
  if (this.getActionBar() != null) {
    this.getActionBar().setHomeButtonEnabled(true);
    this.getActionBar().setTitle(R.string.accounts);
    this.getActionBar().setIcon(R.drawable.ic_navigation_back);
  }
  setContentView(R.layout.manage_account_activity);
  ListView listview=(ListView)findViewById(R.id.email_list);
  if (AppData.appUsers != null) {
    ListAdapter listAdapter=new CustomAdapter(ManageAccountsActivity.this,R.layout.manageaccountsactivity_listitem,R.layout.manageaccountsactivity_listitem_add_new_user_account,R.id.manageactivity_listitemtextvie,(ArrayList<AppUser>)AppData.appUsers);
    listview.setAdapter(listAdapter);
  }
 else {
    showAllAccounts();
  }
  listview.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      ListView listview=(ListView)findViewById(R.id.email_list);
      final AppUser user=(AppUser)listview.getItemAtPosition(position);
      if (user.getId() < 0) {
        showAddUserDialogue(null,null,false);
        return;
      }
      final View ed_dialog_layout=getLayoutInflater().inflate(R.layout.manage_account_option_list,null);
      final AlertDialog dialog=CustomedDialog.getAlertDialogNoTitleNoButton(ManageAccountsActivity.this,ed_dialog_layout);
      dialog.show();
      Button cancel=(Button)ed_dialog_layout.findViewById(R.id.btn_cancel);
      Button openDefault=(Button)ed_dialog_layout.findViewById(R.id.btn_open_account);
      Button setDefault=(Button)ed_dialog_layout.findViewById(R.id.btn_set_default_account);
      Button delete=(Button)ed_dialog_layout.findViewById(R.id.btn_delete_account);
      cancel.setOnClickListener(new OnClickListener(){
        @Override public void onClick(        View v){
          dialog.dismiss();
        }
      }
);
      if (user.getIsDefault()) {
        openDefault.setVisibility(View.GONE);
        setDefault.setVisibility(View.GONE);
      }
 else {
        openDefault.setOnClickListener(new OnClickListener(){
          @Override public void onClick(          View v){
            setDefaultUser(user.getId() + "String_Node_Str",true,dialog);
            ed_dialog_layout.setEnabled(false);
            ed_dialog_layout.setClickable(false);
          }
        }
);
        setDefault.setOnClickListener(new OnClickListener(){
          @Override public void onClick(          View v){
            setDefaultUser(user.getId() + "String_Node_Str",false,dialog);
            ed_dialog_layout.setEnabled(false);
            ed_dialog_layout.setClickable(false);
          }
        }
);
      }
      delete.setOnClickListener(new OnClickListener(){
        @Override public void onClick(        View v){
          CustomedDialog.getConfirmRemoveDialog(ManageAccountsActivity.this,new DialogInterface.OnClickListener(){
            @Override public void onClick(            DialogInterface warningDialog,            int which){
              try {
                DbAppUser users=new DbAppUser(ManageAccountsActivity.this);
                users.deleteAppUserByEmail(user.getEmail());
                if (users.getDefaultUsersCount() == 0 && users.getAppUsersCount() > 0) {
                  int maxid=users.getMaxID();
                  AppUser user=users.getAppUserByID(maxid);
                  user.setIsDefault(true);
                  users.updateAppUser(user);
                  PrefsManager.saveUserEmail(PreferenceManager.getDefaultSharedPreferences(ManageAccountsActivity.this),user.getEmail());
                  AppData.defaultUser=user;
                }
                showAllAccounts();
                dialog.dismiss();
              }
 catch (              Exception e) {
                if (Constants.isAppTrackingEnabled) {
                  BugSenseHandler.sendException(e);
                }
              }
            }
          }
).show();
        }
      }
);
    }
  }
);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (Constants.isAppTrackingEnabled) {
    BugSenseHandler.initAndStartSession(this,Constants.bugsense_ApiKey);
  }
  EvercamPlayApplication.sendScreenAnalytics(this,getString(R.string.screen_manage_account));
  if (this.getActionBar() != null) {
    this.getActionBar().setHomeButtonEnabled(true);
    this.getActionBar().setTitle(R.string.accounts);
    this.getActionBar().setIcon(R.drawable.ic_navigation_back);
  }
  setContentView(R.layout.manage_account_activity);
  ListView listview=(ListView)findViewById(R.id.email_list);
  if (AppData.appUsers != null && AppData.appUsers.size() != 0) {
    ListAdapter listAdapter=new CustomAdapter(ManageAccountsActivity.this,R.layout.manageaccountsactivity_listitem,R.layout.manageaccountsactivity_listitem_add_new_user_account,R.id.manageactivity_listitemtextvie,(ArrayList<AppUser>)AppData.appUsers);
    listview.setAdapter(listAdapter);
  }
 else {
    showAllAccounts();
  }
  listview.setOnItemClickListener(new OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      ListView listview=(ListView)findViewById(R.id.email_list);
      final AppUser user=(AppUser)listview.getItemAtPosition(position);
      if (user.getId() < 0) {
        showAddUserDialogue(null,null,false);
        return;
      }
      final View ed_dialog_layout=getLayoutInflater().inflate(R.layout.manage_account_option_list,null);
      final AlertDialog dialog=CustomedDialog.getAlertDialogNoTitleNoButton(ManageAccountsActivity.this,ed_dialog_layout);
      dialog.show();
      Button cancel=(Button)ed_dialog_layout.findViewById(R.id.btn_cancel);
      Button openDefault=(Button)ed_dialog_layout.findViewById(R.id.btn_open_account);
      Button setDefault=(Button)ed_dialog_layout.findViewById(R.id.btn_set_default_account);
      Button delete=(Button)ed_dialog_layout.findViewById(R.id.btn_delete_account);
      cancel.setOnClickListener(new OnClickListener(){
        @Override public void onClick(        View v){
          dialog.dismiss();
        }
      }
);
      if (user.getIsDefault()) {
        openDefault.setEnabled(false);
        setDefault.setEnabled(false);
      }
 else {
        openDefault.setOnClickListener(new OnClickListener(){
          @Override public void onClick(          View v){
            setDefaultUser(user.getId() + "String_Node_Str",true,dialog);
            ed_dialog_layout.setEnabled(false);
            ed_dialog_layout.setClickable(false);
          }
        }
);
        setDefault.setOnClickListener(new OnClickListener(){
          @Override public void onClick(          View v){
            setDefaultUser(user.getId() + "String_Node_Str",false,dialog);
            ed_dialog_layout.setEnabled(false);
            ed_dialog_layout.setClickable(false);
          }
        }
);
      }
      if (AppData.appUsers != null && AppData.appUsers.size() == 2) {
        delete.setEnabled(false);
      }
 else {
        delete.setOnClickListener(new OnClickListener(){
          @Override public void onClick(          View v){
            CustomedDialog.getConfirmRemoveDialog(ManageAccountsActivity.this,new DialogInterface.OnClickListener(){
              @Override public void onClick(              DialogInterface warningDialog,              int which){
                try {
                  DbAppUser users=new DbAppUser(ManageAccountsActivity.this);
                  users.deleteAppUserByEmail(user.getEmail());
                  if (users.getDefaultUsersCount() == 0 && users.getAppUsersCount() > 0) {
                    int maxid=users.getMaxID();
                    AppUser user=users.getAppUserByID(maxid);
                    user.setIsDefault(true);
                    users.updateAppUser(user);
                    PrefsManager.saveUserEmail(PreferenceManager.getDefaultSharedPreferences(ManageAccountsActivity.this),user.getEmail());
                    AppData.defaultUser=user;
                  }
                  showAllAccounts();
                  dialog.dismiss();
                }
 catch (                Exception e) {
                  if (Constants.isAppTrackingEnabled) {
                    BugSenseHandler.sendException(e);
                  }
                }
              }
            }
).show();
          }
        }
);
      }
    }
  }
);
}