Program: 64751
Project: 64751
Buggy source:
/** 
 * Get the parameters from the intent (parameters sent from the caller). Also used for Tasker integration, for example.
 * @param savedInstanceState parameters
 */
private boolean handleIntent(Bundle savedInstanceState){
  Intent intent=getIntent();
  mIntentAction=intent.getAction();
  if (mIntentAction == null) {
    Timber.w("String_Node_Str");
    return false;
  }
  if (savedInstanceState == null) {
    int accountId=intent.getIntExtra(EditTransactionActivityConstants.KEY_ACCOUNT_ID,Constants.NOT_SET);
    if (accountId != Constants.NOT_SET) {
      mCommon.transactionEntity.setAccountId(accountId);
    }
    if (mIntentAction != null) {
      int transactionId=intent.getIntExtra(EditTransactionActivityConstants.KEY_TRANS_ID,Constants.NOT_SET);
switch (mIntentAction) {
case Intent.ACTION_EDIT:
        loadTransaction(transactionId);
      break;
case Intent.ACTION_PASTE:
    loadTransaction(transactionId);
  duplicateTransaction();
break;
case Intent.ACTION_INSERT:
mRecurringTransactionId=intent.getIntExtra(EditTransactionActivityConstants.KEY_BDID_ID,Constants.NOT_SET);
if (mRecurringTransactionId > Constants.NOT_SET) {
loadRecurringTransaction(mRecurringTransactionId);
}
}
}
}
if (mIntentAction.equals(Intent.ACTION_INSERT)) {
if (mCommon.transactionEntity.getStatus() == null) {
String defaultStatus=PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(getString(PreferenceConstants.PREF_DEFAULT_STATUS),"String_Node_Str");
mCommon.transactionEntity.setStatus(defaultStatus);
}
if ("String_Node_Str".equals(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(getString(PreferenceConstants.PREF_DEFAULT_PAYEE),"String_Node_Str"))) {
AsyncTask<Void,Void,Boolean> task=new AsyncTask<Void,Void,Boolean>(){
@Override protected Boolean doInBackground(Void... params){
try {
Core core=new Core(getApplicationContext());
Payee payee=core.getLastPayeeUsed();
if (payee != null && mCommon.transactionEntity.getPayeeId() == Constants.NOT_SET) {
mCommon.transactionEntity.setPayeeId(payee.getId());
mCommon.payeeName=payee.getName();
mCommon.transactionEntity.setCategoryId(payee.getCategoryId());
mCommon.transactionEntity.setSubcategoryId(payee.getSubcategoryId());
mCommon.loadCategoryName();
return Boolean.TRUE;
}
}
 catch (Exception e) {
Timber.e(e,"String_Node_Str");
}
return Boolean.FALSE;
}
@Override protected void onPostExecute(Boolean result){
super.onPostExecute(result);
if (result) {
try {
mCommon.showPayeeName();
mCommon.displayCategoryName();
}
 catch (Exception e) {
Timber.e(e,"String_Node_Str");
}
}
}
}
;
task.execute();
}
if (intent.getData() != null) {
externalIntegration(intent);
}
 else {
try {
Bundle extras=intent.getExtras();
if (extras != null) {
AccountRepository accountRepository=new AccountRepository(this);
if (Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_ACCOUNT_ID)) > 0) {
mCommon.transactionEntity.setAccountId(Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_ACCOUNT_ID)));
mCommon.transactionEntity.setAccountToId(Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_TO_ACCOUNT_ID)));
CurrencyService currencyService=new CurrencyService(this);
mCommon.transactionEntity.setAmountTo(currencyService.doCurrencyExchange(accountRepository.loadCurrencyIdFor(mCommon.transactionEntity.getAccountId()),mCommon.transactionEntity.getAmount(),accountRepository.loadCurrencyIdFor(mCommon.transactionEntity.getAccountToId())));
}
mCommon.transactionEntity.setTransactionType(TransactionTypes.valueOf(extras.getString(EditTransactionActivityConstants.KEY_TRANS_CODE)));
mCommon.transactionEntity.setAmount(MoneyFactory.fromString(extras.getString(EditTransactionActivityConstants.KEY_TRANS_AMOUNT)));
mCommon.transactionEntity.setNotes(extras.getString(EditTransactionActivityConstants.KEY_NOTES));
mCommon.transactionEntity.setDate(new MmxDate().toDate());
if (extras.getString(EditTransactionActivityConstants.KEY_PAYEE_NAME).isEmpty()) {
if ("String_Node_Str".equals(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(getString(PreferenceConstants.PREF_DEFAULT_PAYEE),"String_Node_Str"))) {
Core core=new Core(this);
Payee payee=core.getLastPayeeUsed();
if (payee != null) {
  mCommon.transactionEntity.setPayeeId(payee.getId());
  mCommon.payeeName=payee.getName();
  mCommon.setCategoryFromPayee(mCommon.transactionEntity.getPayeeId());
}
}
}
 else {
mCommon.transactionEntity.setPayeeId(Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_PAYEE_ID)));
mCommon.payeeName=extras.getString(EditTransactionActivityConstants.KEY_PAYEE_NAME);
mCommon.setCategoryFromPayee(mCommon.transactionEntity.getPayeeId());
}
if (extras.getString(EditTransactionActivityConstants.KEY_PAYEE_NAME).isEmpty()) {
String catID=extras.getString(EditTransactionActivityConstants.KEY_CATEGORY_ID);
String subCatID=extras.getString(EditTransactionActivityConstants.KEY_SUBCATEGORY_ID);
if (!catID.isEmpty()) {
mCommon.transactionEntity.setCategoryId(parseInt(catID));
}
if (!subCatID.isEmpty()) {
mCommon.transactionEntity.setSubcategoryId(parseInt(subCatID));
}
}
mCommon.mToAccountName=accountRepository.loadName(mCommon.transactionEntity.getAccountToId());
extras=null;
}
}
 catch (Exception e) {
Toast.makeText(this,"String_Node_Str" + e,Toast.LENGTH_LONG).show();
}
}
Integer account=mCommon.transactionEntity.getAccountId();
if (account == null || account == Constants.NOT_SET) {
AppSettings settings=new AppSettings(this);
Integer defaultAccountId=settings.getGeneralSettings().getDefaultAccountId();
if (defaultAccountId == null) {
new UIHelper(this).showToast(getString(R.string.default_account_not_set));
return false;
}
 else {
mCommon.transactionEntity.setAccountId(defaultAccountId);
}
}
}
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(Intent.ACTION_INSERT.equals(mIntentAction) ? R.string.new_transaction : R.string.edit_transaction);
}
return true;
}

Fixed version (ground truth):
/** 
 * Get the parameters from the intent (parameters sent from the caller). Also used for Tasker integration, for example.
 * @param savedInstanceState parameters
 */
private boolean handleIntent(Bundle savedInstanceState){
  Intent intent=getIntent();
  mIntentAction=intent.getAction();
  if (mIntentAction == null) {
    Timber.w("String_Node_Str");
    return false;
  }
  if (savedInstanceState == null) {
    int accountId=intent.getIntExtra(EditTransactionActivityConstants.KEY_ACCOUNT_ID,Constants.NOT_SET);
    if (accountId != Constants.NOT_SET) {
      mCommon.transactionEntity.setAccountId(accountId);
    }
    if (mIntentAction != null) {
      int transactionId=intent.getIntExtra(EditTransactionActivityConstants.KEY_TRANS_ID,Constants.NOT_SET);
switch (mIntentAction) {
case Intent.ACTION_EDIT:
        loadTransaction(transactionId);
      break;
case Intent.ACTION_PASTE:
    loadTransaction(transactionId);
  duplicateTransaction();
break;
case Intent.ACTION_INSERT:
mRecurringTransactionId=intent.getIntExtra(EditTransactionActivityConstants.KEY_BDID_ID,Constants.NOT_SET);
if (mRecurringTransactionId > Constants.NOT_SET) {
loadRecurringTransaction(mRecurringTransactionId);
}
}
}
}
if (mIntentAction.equals(Intent.ACTION_INSERT)) {
if (mCommon.transactionEntity.getStatus() == null) {
String defaultStatus=PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(getString(PreferenceConstants.PREF_DEFAULT_STATUS),"String_Node_Str");
mCommon.transactionEntity.setStatus(defaultStatus);
}
if ("String_Node_Str".equals(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(getString(PreferenceConstants.PREF_DEFAULT_PAYEE),"String_Node_Str"))) {
AsyncTask<Void,Void,Boolean> task=new AsyncTask<Void,Void,Boolean>(){
@Override protected Boolean doInBackground(Void... params){
try {
Core core=new Core(getApplicationContext());
Payee payee=core.getLastPayeeUsed();
if (payee != null && mCommon.transactionEntity.getPayeeId() == Constants.NOT_SET) {
mCommon.transactionEntity.setPayeeId(payee.getId());
mCommon.payeeName=payee.getName();
mCommon.transactionEntity.setCategoryId(payee.getCategoryId());
mCommon.transactionEntity.setSubcategoryId(payee.getSubcategoryId());
mCommon.loadCategoryName();
return Boolean.TRUE;
}
}
 catch (Exception e) {
Timber.e(e,"String_Node_Str");
}
return Boolean.FALSE;
}
@Override protected void onPostExecute(Boolean result){
super.onPostExecute(result);
if (result) {
try {
mCommon.showPayeeName();
mCommon.displayCategoryName();
}
 catch (Exception e) {
Timber.e(e,"String_Node_Str");
}
}
}
}
;
task.execute();
}
if (intent.getData() != null) {
externalIntegration(intent);
}
 else {
try {
Bundle extras=intent.getExtras();
if (extras != null) {
AccountRepository accountRepository=new AccountRepository(this);
if (Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_ACCOUNT_ID)) > 0) {
mCommon.transactionEntity.setAccountId(Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_ACCOUNT_ID)));
mCommon.transactionEntity.setAccountToId(Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_TO_ACCOUNT_ID)));
CurrencyService currencyService=new CurrencyService(this);
mCommon.transactionEntity.setAmountTo(currencyService.doCurrencyExchange(accountRepository.loadCurrencyIdFor(mCommon.transactionEntity.getAccountId()),mCommon.transactionEntity.getAmount(),accountRepository.loadCurrencyIdFor(mCommon.transactionEntity.getAccountToId())));
}
mCommon.transactionEntity.setTransactionType(TransactionTypes.valueOf(extras.getString(EditTransactionActivityConstants.KEY_TRANS_CODE)));
mCommon.transactionEntity.setAmount(MoneyFactory.fromString(extras.getString(EditTransactionActivityConstants.KEY_TRANS_AMOUNT)));
mCommon.transactionEntity.setNotes(extras.getString(EditTransactionActivityConstants.KEY_NOTES));
mCommon.transactionEntity.setDate(new MmxDate().toDate());
if (extras.getString(EditTransactionActivityConstants.KEY_PAYEE_NAME).isEmpty()) {
mCommon.payeeName="String_Node_Str";
if ("String_Node_Str".equals(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(getString(PreferenceConstants.PREF_DEFAULT_PAYEE),"String_Node_Str"))) {
Core core=new Core(this);
Payee payee=core.getLastPayeeUsed();
if (payee != null) {
  mCommon.transactionEntity.setPayeeId(payee.getId());
  mCommon.payeeName=payee.getName();
  mCommon.setCategoryFromPayee(mCommon.transactionEntity.getPayeeId());
}
}
}
 else {
mCommon.transactionEntity.setPayeeId(Integer.parseInt(extras.getString(EditTransactionActivityConstants.KEY_PAYEE_ID)));
mCommon.payeeName=extras.getString(EditTransactionActivityConstants.KEY_PAYEE_NAME);
mCommon.setCategoryFromPayee(mCommon.transactionEntity.getPayeeId());
}
if (mCommon.payeeName.isEmpty()) {
String catID=extras.getString(EditTransactionActivityConstants.KEY_CATEGORY_ID);
String subCatID=extras.getString(EditTransactionActivityConstants.KEY_SUBCATEGORY_ID);
if (!catID.isEmpty()) {
mCommon.transactionEntity.setCategoryId(parseInt(catID));
}
if (!subCatID.isEmpty()) {
mCommon.transactionEntity.setSubcategoryId(parseInt(subCatID));
}
mCommon.loadCategoryName();
}
mCommon.mToAccountName=accountRepository.loadName(mCommon.transactionEntity.getAccountToId());
extras=null;
}
}
 catch (Exception e) {
Toast.makeText(this,"String_Node_Str" + e,Toast.LENGTH_LONG).show();
}
}
Integer account=mCommon.transactionEntity.getAccountId();
if (account == null || account == Constants.NOT_SET) {
AppSettings settings=new AppSettings(this);
Integer defaultAccountId=settings.getGeneralSettings().getDefaultAccountId();
if (defaultAccountId == null) {
new UIHelper(this).showToast(getString(R.string.default_account_not_set));
return false;
}
 else {
mCommon.transactionEntity.setAccountId(defaultAccountId);
}
}
}
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(Intent.ACTION_INSERT.equals(mIntentAction) ? R.string.new_transaction : R.string.edit_transaction);
}
return true;
}