Program: 64784
Project: 64784
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setDialogMode(true);
  if ((savedInstanceState != null)) {
    mTransId=savedInstanceState.getInt(KEY_TRANS_ID);
    mAccountId=savedInstanceState.getInt(KEY_ACCOUNT_ID);
    mToAccountId=savedInstanceState.getInt(KEY_TO_ACCOUNT_ID);
    mToAccountName=savedInstanceState.getString(KEY_TO_ACCOUNT_NAME);
    mDate=savedInstanceState.getString(KEY_TRANS_DATE);
    mTransCode=savedInstanceState.getString(KEY_TRANS_CODE);
    mStatus=savedInstanceState.getString(KEY_TRANS_STATUS);
    mAmount=savedInstanceState.getDouble(KEY_TRANS_AMOUNT);
    mTotAmount=savedInstanceState.getDouble(KEY_TRANS_TOTAMOUNT);
    mPayeeId=savedInstanceState.getInt(KEY_PAYEE_ID);
    mPayeeName=savedInstanceState.getString(KEY_PAYEE_NAME);
    mCategoryId=savedInstanceState.getInt(KEY_CATEGORY_ID);
    mCategoryName=savedInstanceState.getString(KEY_CATEGORY_NAME);
    mSubCategoryId=savedInstanceState.getInt(KEY_SUBCATEGORY_ID);
    mSubCategoryName=savedInstanceState.getString(KEY_SUBCATEGORY_NAME);
    mNotes=savedInstanceState.getString(KEY_NOTES);
    mTransNumber=savedInstanceState.getString(KEY_TRANS_NUMBER);
    mSplitTransaction=savedInstanceState.getParcelableArrayList(KEY_SPLIT_TRANSACTION);
    mSplitTransactionDeleted=savedInstanceState.getParcelableArrayList(KEY_SPLIT_TRANSACTION_DELETED);
    mBdId=savedInstanceState.getInt(KEY_BDID_ID);
    mNextOccurrence=savedInstanceState.getString(KEY_NEXT_OCCURRENCE);
    mIntentAction=savedInstanceState.getString(KEY_ACTION);
  }
  if (getIntent() != null) {
    if (savedInstanceState == null) {
      mAccountId=getIntent().getIntExtra(KEY_ACCOUNT_ID,-1);
      if (getIntent().getAction() != null && Intent.ACTION_EDIT.equals(getIntent().getAction())) {
        mTransId=getIntent().getIntExtra(KEY_TRANS_ID,-1);
        getCheckingAccount(mTransId,false);
      }
 else       if (getIntent().getAction() != null && Intent.ACTION_PASTE.equals(getIntent().getAction())) {
        getCheckingAccount(getIntent().getIntExtra(KEY_TRANS_ID,-1),true);
      }
 else {
        if (getIntent().getIntExtra(KEY_BDID_ID,-1) > -1) {
          mBdId=getIntent().getIntExtra(KEY_BDID_ID,-1);
          mNextOccurrence=getIntent().getStringExtra(KEY_NEXT_OCCURRENCE);
          getRepeatingTransaction(mBdId);
        }
      }
    }
    mIntentAction=getIntent().getAction();
    if (Constants.INTENT_ACTION_INSERT.equals(mIntentAction)) {
      if (mStatus == null)       mStatus=PreferenceManager.getDefaultSharedPreferences(this).getString(getString(PreferencesConstant.PREF_DEFAULT_STATUS),"String_Node_Str");
      if ("String_Node_Str".equals(PreferenceManager.getDefaultSharedPreferences(this).getString(getString(PreferencesConstant.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(CheckingAccountActivity.this);
              TablePayee payee=core.getLastPayeeUsed();
              if (payee != null && mPayeeId == -1) {
                mPayeeId=payee.getPayeeId();
                mPayeeName=payee.getPayeeName();
                mCategoryId=payee.getCategId();
                mSubCategoryId=payee.getSubCategId();
                getCategSubName(mCategoryId,mSubCategoryId);
                return Boolean.TRUE;
              }
            }
 catch (            Exception e) {
              Log.e(LOGCAT,e.getMessage());
            }
            return Boolean.FALSE;
          }
          @Override protected void onPostExecute(          Boolean result){
            super.onPostExecute(result);
            if (result) {
              try {
                refreshPayeeName();
                refreshCategoryName();
              }
 catch (              Exception e) {
                Log.e(LOGCAT,e.getMessage());
              }
            }
          }
        }
;
        task.execute();
      }
    }
    getSupportActionBar().setTitle(Constants.INTENT_ACTION_INSERT.equals(mIntentAction) ? R.string.new_transaction : R.string.edit_transaction);
  }
  setContentView(R.layout.checkingaccount_activity);
  spinAccount=(Spinner)findViewById(R.id.spinnerAccount);
  mAccountList=MoneyManagerOpenHelper.getInstance(this).getListAccounts(MoneyManagerApplication.getInstanceApp().getAccountsOpenVisible(),MoneyManagerApplication.getInstanceApp().getAccountFavoriteVisible());
  for (int i=0; i <= mAccountList.size() - 1; i++) {
    mAccountNameList.add(mAccountList.get(i).getAccountName());
    mAccountIdList.add(mAccountList.get(i).getAccountId());
  }
  ArrayAdapter<String> adapterAccount=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,mAccountNameList);
  adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinAccount.setAdapter(adapterAccount);
  if (mAccountIdList.indexOf(mAccountId) >= 0) {
    spinAccount.setSelection(mAccountIdList.indexOf(mAccountId),true);
  }
  spinAccount.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mAccountIdList.size())) {
        mAccountId=mAccountIdList.get(position);
        if (Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode)) {
          formatAmount(txtAmount,(Double)txtAmount.getTag(),mAccountId);
        }
 else {
          formatAmount(txtTotAmount,(Double)txtTotAmount.getTag(),mAccountId);
        }
        refreshHeaderAmount();
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  spinToAccount=(Spinner)findViewById(R.id.spinnerToAccount);
  adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinToAccount.setAdapter(adapterAccount);
  if (mToAccountId != -1) {
    if (mAccountIdList.indexOf(mToAccountId) >= 0) {
      spinToAccount.setSelection(mAccountIdList.indexOf(mToAccountId),true);
    }
  }
  spinToAccount.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mAccountIdList.size())) {
        mToAccountId=mAccountIdList.get(position);
        formatAmount(txtAmount,(Double)txtAmount.getTag(),mAccountId);
        formatAmount(txtTotAmount,(Double)txtTotAmount.getTag(),mToAccountId);
        refreshHeaderAmount();
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  spinTransCode=(Spinner)findViewById(R.id.spinnerTransCode);
  mTransCodeItems=getResources().getStringArray(R.array.transcode_items);
  mTransCodeValues=getResources().getStringArray(R.array.transcode_values);
  ArrayAdapter<String> adapterTrans=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,mTransCodeItems);
  adapterTrans.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinTransCode.setAdapter(adapterTrans);
  if (TextUtils.isEmpty(mTransCode) == false) {
    if (Arrays.asList(mTransCodeValues).indexOf(mTransCode) >= 0) {
      spinTransCode.setSelection(Arrays.asList(mTransCodeValues).indexOf(mTransCode),true);
    }
  }
 else {
    mTransCode=(String)spinTransCode.getSelectedItem();
  }
  spinTransCode.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mTransCodeValues.length)) {
        mTransCode=mTransCodeValues[position];
      }
      refreshTransCode();
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  spinStatus=(Spinner)findViewById(R.id.spinnerStatus);
  mStatusItems=getResources().getStringArray(R.array.status_items);
  mStatusValues=getResources().getStringArray(R.array.status_values);
  ArrayAdapter<String> adapterStatus=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,mStatusItems);
  adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinStatus.setAdapter(adapterStatus);
  if (!(TextUtils.isEmpty(mStatus))) {
    if (Arrays.asList(mStatusValues).indexOf(mStatus) >= 0) {
      spinStatus.setSelection(Arrays.asList(mStatusValues).indexOf(mStatus),true);
    }
  }
 else {
    mStatus=(String)spinStatus.getSelectedItem();
  }
  spinStatus.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mStatusValues.length)) {
        mStatus=mStatusValues[position];
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  txtSelectDate=(TextView)findViewById(R.id.textViewDate);
  if (!(TextUtils.isEmpty(mDate))) {
    try {
      txtSelectDate.setTag(new SimpleDateFormat("String_Node_Str").parse(mDate));
    }
 catch (    ParseException e) {
      Log.e(LOGCAT,e.getMessage());
    }
  }
 else {
    txtSelectDate.setTag((Date)Calendar.getInstance().getTime());
  }
  formatExtendedDate(txtSelectDate);
  txtSelectDate.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Calendar date=Calendar.getInstance();
      date.setTime((Date)txtSelectDate.getTag());
      DatePickerDialog dialog=new DatePickerDialog(CheckingAccountActivity.this,mDateSetListener,date.get(Calendar.YEAR),date.get(Calendar.MONTH),date.get(Calendar.DATE));
      dialog.show();
    }
    public DatePickerDialog.OnDateSetListener mDateSetListener=new DatePickerDialog.OnDateSetListener(){
      @Override public void onDateSet(      DatePicker view,      int year,      int monthOfYear,      int dayOfMonth){
        try {
          Date date=new SimpleDateFormat("String_Node_Str").parse(Integer.toString(year) + "String_Node_Str" + Integer.toString(monthOfYear + 1)+ "String_Node_Str"+ Integer.toString(dayOfMonth));
          txtSelectDate.setTag(date);
          formatExtendedDate(txtSelectDate);
        }
 catch (        Exception e) {
          Log.e(LOGCAT,e.getMessage());
        }
      }
    }
;
  }
);
  txtSelectPayee=(TextView)findViewById(R.id.textViewPayee);
  txtSelectPayee.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(CheckingAccountActivity.this,PayeeActivity.class);
      intent.setAction(Intent.ACTION_PICK);
      startActivityForResult(intent,REQUEST_PICK_PAYEE);
    }
  }
);
  txtSelectCategory=(TextView)findViewById(R.id.textViewCategory);
  txtSelectCategory.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!chbSplitTransaction.isChecked()) {
        Intent intent=new Intent(CheckingAccountActivity.this,CategorySubCategoryExpandableListActivity.class);
        intent.setAction(Intent.ACTION_PICK);
        startActivityForResult(intent,REQUEST_PICK_CATEGORY);
      }
 else {
        Intent intent=new Intent(CheckingAccountActivity.this,SplitTransactionsActivity.class);
        intent.putParcelableArrayListExtra(SplitTransactionsActivity.KEY_SPLIT_TRANSACTION,mSplitTransaction);
        intent.putParcelableArrayListExtra(SplitTransactionsActivity.KEY_SPLIT_TRANSACTION_DELETED,mSplitTransactionDeleted);
        startActivityForResult(intent,REQUEST_PICK_SPLIT_TRANSACTION);
      }
    }
  }
);
  chbSplitTransaction=(CheckBox)findViewById(R.id.checkBoxSplitTransaction);
  chbSplitTransaction.setChecked(mSplitTransaction != null && mSplitTransaction.size() >= 0);
  chbSplitTransaction.setOnCheckedChangeListener(new OnCheckedChangeListener(){
    @Override public void onCheckedChanged(    CompoundButton buttonView,    boolean isChecked){
      CheckingAccountActivity.this.refreshCategoryName();
    }
  }
);
  OnClickListener onClickAmount=new OnClickListener(){
    @Override public void onClick(    View v){
      Integer currencyId=null;
      if (txtTotAmount.equals(v)) {
        if (spinAccount.getSelectedItemPosition() >= 0 && spinAccount.getSelectedItemPosition() < mAccountList.size()) {
          if (Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode)) {
            currencyId=mAccountList.get(spinToAccount.getSelectedItemPosition()).getCurrencyId();
          }
 else {
            currencyId=mAccountList.get(spinAccount.getSelectedItemPosition()).getCurrencyId();
          }
        }
      }
 else {
        if (spinToAccount.getSelectedItemPosition() >= 0 && spinToAccount.getSelectedItemPosition() < mAccountList.size()) {
          currencyId=mAccountList.get(spinAccount.getSelectedItemPosition()).getCurrencyId();
        }
      }
      double amount=(Double)((TextView)v).getTag();
      InputAmountDialog dialog=InputAmountDialog.getInstance(v.getId(),amount,currencyId);
      dialog.show(getSupportFragmentManager(),dialog.getClass().getSimpleName());
    }
  }
;
  txtTotAmount=(TextView)findViewById(R.id.textViewTotAmount);
  formatAmount(txtTotAmount,mTotAmount,!Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode) ? mAccountId : mToAccountId);
  txtTotAmount.setOnClickListener(onClickAmount);
  txtAmount=(TextView)findViewById(R.id.textViewAmount);
  formatAmount(txtAmount,mAmount,!Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode) ? mToAccountId : mAccountId);
  txtAmount.setOnClickListener(onClickAmount);
  edtTransNumber=(EditText)findViewById(R.id.editTextTransNumber);
  if (!TextUtils.isEmpty(mTransNumber)) {
    edtTransNumber.setText(mTransNumber);
  }
  btnTransNumber=(ImageButton)findViewById(R.id.buttonTransNumber);
  btnTransNumber.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      MoneyManagerOpenHelper helper=MoneyManagerOpenHelper.getInstance(CheckingAccountActivity.this);
      String query="String_Node_Str" + TableCheckingAccount.TRANSACTIONNUMBER + "String_Node_Str"+ new TableCheckingAccount().getSource()+ "String_Node_Str"+ TableCheckingAccount.ACCOUNTID+ "String_Node_Str";
      Cursor cursor=helper.getReadableDatabase().rawQuery(query,new String[]{Integer.toString(mAccountId)});
      if (cursor != null && cursor.moveToFirst()) {
        String transNumber=cursor.getString(0);
        if (TextUtils.isEmpty(transNumber)) {
          transNumber="String_Node_Str";
        }
        if ((!TextUtils.isEmpty(transNumber)) && TextUtils.isDigitsOnly(transNumber)) {
          try {
            edtTransNumber.setText(Long.toString(Long.parseLong(transNumber) + 1));
          }
 catch (          Exception e) {
            Log.e(LOGCAT,e.getMessage());
          }
        }
        cursor.close();
      }
    }
  }
);
  edtNotes=(EditText)findViewById(R.id.editTextNotes);
  if (!(TextUtils.isEmpty(mNotes))) {
    edtNotes.setText(mNotes);
  }
  refreshTransCode();
  refreshPayeeName();
  refreshCategoryName();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  try {
    DropboxHelper.getInstance();
  }
 catch (  Exception e) {
    Log.e(LOGCAT,e.getMessage());
    DropboxHelper.getInstance(getApplicationContext());
  }
  setDialogMode(true);
  if ((savedInstanceState != null)) {
    mTransId=savedInstanceState.getInt(KEY_TRANS_ID);
    mAccountId=savedInstanceState.getInt(KEY_ACCOUNT_ID);
    mToAccountId=savedInstanceState.getInt(KEY_TO_ACCOUNT_ID);
    mToAccountName=savedInstanceState.getString(KEY_TO_ACCOUNT_NAME);
    mDate=savedInstanceState.getString(KEY_TRANS_DATE);
    mTransCode=savedInstanceState.getString(KEY_TRANS_CODE);
    mStatus=savedInstanceState.getString(KEY_TRANS_STATUS);
    mAmount=savedInstanceState.getDouble(KEY_TRANS_AMOUNT);
    mTotAmount=savedInstanceState.getDouble(KEY_TRANS_TOTAMOUNT);
    mPayeeId=savedInstanceState.getInt(KEY_PAYEE_ID);
    mPayeeName=savedInstanceState.getString(KEY_PAYEE_NAME);
    mCategoryId=savedInstanceState.getInt(KEY_CATEGORY_ID);
    mCategoryName=savedInstanceState.getString(KEY_CATEGORY_NAME);
    mSubCategoryId=savedInstanceState.getInt(KEY_SUBCATEGORY_ID);
    mSubCategoryName=savedInstanceState.getString(KEY_SUBCATEGORY_NAME);
    mNotes=savedInstanceState.getString(KEY_NOTES);
    mTransNumber=savedInstanceState.getString(KEY_TRANS_NUMBER);
    mSplitTransaction=savedInstanceState.getParcelableArrayList(KEY_SPLIT_TRANSACTION);
    mSplitTransactionDeleted=savedInstanceState.getParcelableArrayList(KEY_SPLIT_TRANSACTION_DELETED);
    mBdId=savedInstanceState.getInt(KEY_BDID_ID);
    mNextOccurrence=savedInstanceState.getString(KEY_NEXT_OCCURRENCE);
    mIntentAction=savedInstanceState.getString(KEY_ACTION);
  }
  if (getIntent() != null) {
    if (savedInstanceState == null) {
      mAccountId=getIntent().getIntExtra(KEY_ACCOUNT_ID,-1);
      if (getIntent().getAction() != null && Intent.ACTION_EDIT.equals(getIntent().getAction())) {
        mTransId=getIntent().getIntExtra(KEY_TRANS_ID,-1);
        getCheckingAccount(mTransId,false);
      }
 else       if (getIntent().getAction() != null && Intent.ACTION_PASTE.equals(getIntent().getAction())) {
        getCheckingAccount(getIntent().getIntExtra(KEY_TRANS_ID,-1),true);
      }
 else {
        if (getIntent().getIntExtra(KEY_BDID_ID,-1) > -1) {
          mBdId=getIntent().getIntExtra(KEY_BDID_ID,-1);
          mNextOccurrence=getIntent().getStringExtra(KEY_NEXT_OCCURRENCE);
          getRepeatingTransaction(mBdId);
        }
      }
    }
    mIntentAction=getIntent().getAction();
    if (Constants.INTENT_ACTION_INSERT.equals(mIntentAction)) {
      if (mStatus == null)       mStatus=PreferenceManager.getDefaultSharedPreferences(this).getString(getString(PreferencesConstant.PREF_DEFAULT_STATUS),"String_Node_Str");
      if ("String_Node_Str".equals(PreferenceManager.getDefaultSharedPreferences(this).getString(getString(PreferencesConstant.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(CheckingAccountActivity.this);
              TablePayee payee=core.getLastPayeeUsed();
              if (payee != null && mPayeeId == -1) {
                mPayeeId=payee.getPayeeId();
                mPayeeName=payee.getPayeeName();
                mCategoryId=payee.getCategId();
                mSubCategoryId=payee.getSubCategId();
                getCategSubName(mCategoryId,mSubCategoryId);
                return Boolean.TRUE;
              }
            }
 catch (            Exception e) {
              Log.e(LOGCAT,e.getMessage());
            }
            return Boolean.FALSE;
          }
          @Override protected void onPostExecute(          Boolean result){
            super.onPostExecute(result);
            if (result) {
              try {
                refreshPayeeName();
                refreshCategoryName();
              }
 catch (              Exception e) {
                Log.e(LOGCAT,e.getMessage());
              }
            }
          }
        }
;
        task.execute();
      }
    }
    getSupportActionBar().setTitle(Constants.INTENT_ACTION_INSERT.equals(mIntentAction) ? R.string.new_transaction : R.string.edit_transaction);
  }
  setContentView(R.layout.checkingaccount_activity);
  spinAccount=(Spinner)findViewById(R.id.spinnerAccount);
  mAccountList=MoneyManagerOpenHelper.getInstance(this).getListAccounts(MoneyManagerApplication.getInstanceApp().getAccountsOpenVisible(),MoneyManagerApplication.getInstanceApp().getAccountFavoriteVisible());
  for (int i=0; i <= mAccountList.size() - 1; i++) {
    mAccountNameList.add(mAccountList.get(i).getAccountName());
    mAccountIdList.add(mAccountList.get(i).getAccountId());
  }
  ArrayAdapter<String> adapterAccount=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,mAccountNameList);
  adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinAccount.setAdapter(adapterAccount);
  if (mAccountIdList.indexOf(mAccountId) >= 0) {
    spinAccount.setSelection(mAccountIdList.indexOf(mAccountId),true);
  }
  spinAccount.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mAccountIdList.size())) {
        mAccountId=mAccountIdList.get(position);
        if (Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode)) {
          formatAmount(txtAmount,(Double)txtAmount.getTag(),mAccountId);
        }
 else {
          formatAmount(txtTotAmount,(Double)txtTotAmount.getTag(),mAccountId);
        }
        refreshHeaderAmount();
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  spinToAccount=(Spinner)findViewById(R.id.spinnerToAccount);
  adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinToAccount.setAdapter(adapterAccount);
  if (mToAccountId != -1) {
    if (mAccountIdList.indexOf(mToAccountId) >= 0) {
      spinToAccount.setSelection(mAccountIdList.indexOf(mToAccountId),true);
    }
  }
  spinToAccount.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mAccountIdList.size())) {
        mToAccountId=mAccountIdList.get(position);
        formatAmount(txtAmount,(Double)txtAmount.getTag(),mAccountId);
        formatAmount(txtTotAmount,(Double)txtTotAmount.getTag(),mToAccountId);
        refreshHeaderAmount();
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  spinTransCode=(Spinner)findViewById(R.id.spinnerTransCode);
  mTransCodeItems=getResources().getStringArray(R.array.transcode_items);
  mTransCodeValues=getResources().getStringArray(R.array.transcode_values);
  ArrayAdapter<String> adapterTrans=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,mTransCodeItems);
  adapterTrans.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinTransCode.setAdapter(adapterTrans);
  if (TextUtils.isEmpty(mTransCode) == false) {
    if (Arrays.asList(mTransCodeValues).indexOf(mTransCode) >= 0) {
      spinTransCode.setSelection(Arrays.asList(mTransCodeValues).indexOf(mTransCode),true);
    }
  }
 else {
    mTransCode=(String)spinTransCode.getSelectedItem();
  }
  spinTransCode.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mTransCodeValues.length)) {
        mTransCode=mTransCodeValues[position];
      }
      refreshTransCode();
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  spinStatus=(Spinner)findViewById(R.id.spinnerStatus);
  mStatusItems=getResources().getStringArray(R.array.status_items);
  mStatusValues=getResources().getStringArray(R.array.status_values);
  ArrayAdapter<String> adapterStatus=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,mStatusItems);
  adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinStatus.setAdapter(adapterStatus);
  if (!(TextUtils.isEmpty(mStatus))) {
    if (Arrays.asList(mStatusValues).indexOf(mStatus) >= 0) {
      spinStatus.setSelection(Arrays.asList(mStatusValues).indexOf(mStatus),true);
    }
  }
 else {
    mStatus=(String)spinStatus.getSelectedItem();
  }
  spinStatus.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> parent,    View view,    int position,    long id){
      if ((position >= 0) && (position <= mStatusValues.length)) {
        mStatus=mStatusValues[position];
      }
    }
    @Override public void onNothingSelected(    AdapterView<?> parent){
    }
  }
);
  txtSelectDate=(TextView)findViewById(R.id.textViewDate);
  if (!(TextUtils.isEmpty(mDate))) {
    try {
      txtSelectDate.setTag(new SimpleDateFormat("String_Node_Str").parse(mDate));
    }
 catch (    ParseException e) {
      Log.e(LOGCAT,e.getMessage());
    }
  }
 else {
    txtSelectDate.setTag((Date)Calendar.getInstance().getTime());
  }
  formatExtendedDate(txtSelectDate);
  txtSelectDate.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Calendar date=Calendar.getInstance();
      date.setTime((Date)txtSelectDate.getTag());
      DatePickerDialog dialog=new DatePickerDialog(CheckingAccountActivity.this,mDateSetListener,date.get(Calendar.YEAR),date.get(Calendar.MONTH),date.get(Calendar.DATE));
      dialog.show();
    }
    public DatePickerDialog.OnDateSetListener mDateSetListener=new DatePickerDialog.OnDateSetListener(){
      @Override public void onDateSet(      DatePicker view,      int year,      int monthOfYear,      int dayOfMonth){
        try {
          Date date=new SimpleDateFormat("String_Node_Str").parse(Integer.toString(year) + "String_Node_Str" + Integer.toString(monthOfYear + 1)+ "String_Node_Str"+ Integer.toString(dayOfMonth));
          txtSelectDate.setTag(date);
          formatExtendedDate(txtSelectDate);
        }
 catch (        Exception e) {
          Log.e(LOGCAT,e.getMessage());
        }
      }
    }
;
  }
);
  txtSelectPayee=(TextView)findViewById(R.id.textViewPayee);
  txtSelectPayee.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(CheckingAccountActivity.this,PayeeActivity.class);
      intent.setAction(Intent.ACTION_PICK);
      startActivityForResult(intent,REQUEST_PICK_PAYEE);
    }
  }
);
  txtSelectCategory=(TextView)findViewById(R.id.textViewCategory);
  txtSelectCategory.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (!chbSplitTransaction.isChecked()) {
        Intent intent=new Intent(CheckingAccountActivity.this,CategorySubCategoryExpandableListActivity.class);
        intent.setAction(Intent.ACTION_PICK);
        startActivityForResult(intent,REQUEST_PICK_CATEGORY);
      }
 else {
        Intent intent=new Intent(CheckingAccountActivity.this,SplitTransactionsActivity.class);
        intent.putParcelableArrayListExtra(SplitTransactionsActivity.KEY_SPLIT_TRANSACTION,mSplitTransaction);
        intent.putParcelableArrayListExtra(SplitTransactionsActivity.KEY_SPLIT_TRANSACTION_DELETED,mSplitTransactionDeleted);
        startActivityForResult(intent,REQUEST_PICK_SPLIT_TRANSACTION);
      }
    }
  }
);
  chbSplitTransaction=(CheckBox)findViewById(R.id.checkBoxSplitTransaction);
  chbSplitTransaction.setChecked(mSplitTransaction != null && mSplitTransaction.size() >= 0);
  chbSplitTransaction.setOnCheckedChangeListener(new OnCheckedChangeListener(){
    @Override public void onCheckedChanged(    CompoundButton buttonView,    boolean isChecked){
      CheckingAccountActivity.this.refreshCategoryName();
    }
  }
);
  OnClickListener onClickAmount=new OnClickListener(){
    @Override public void onClick(    View v){
      Integer currencyId=null;
      if (txtTotAmount.equals(v)) {
        if (spinAccount.getSelectedItemPosition() >= 0 && spinAccount.getSelectedItemPosition() < mAccountList.size()) {
          if (Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode)) {
            currencyId=mAccountList.get(spinToAccount.getSelectedItemPosition()).getCurrencyId();
          }
 else {
            currencyId=mAccountList.get(spinAccount.getSelectedItemPosition()).getCurrencyId();
          }
        }
      }
 else {
        if (spinToAccount.getSelectedItemPosition() >= 0 && spinToAccount.getSelectedItemPosition() < mAccountList.size()) {
          currencyId=mAccountList.get(spinAccount.getSelectedItemPosition()).getCurrencyId();
        }
      }
      double amount=(Double)((TextView)v).getTag();
      InputAmountDialog dialog=InputAmountDialog.getInstance(v.getId(),amount,currencyId);
      dialog.show(getSupportFragmentManager(),dialog.getClass().getSimpleName());
    }
  }
;
  txtTotAmount=(TextView)findViewById(R.id.textViewTotAmount);
  formatAmount(txtTotAmount,mTotAmount,!Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode) ? mAccountId : mToAccountId);
  txtTotAmount.setOnClickListener(onClickAmount);
  txtAmount=(TextView)findViewById(R.id.textViewAmount);
  formatAmount(txtAmount,mAmount,!Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode) ? mToAccountId : mAccountId);
  txtAmount.setOnClickListener(onClickAmount);
  edtTransNumber=(EditText)findViewById(R.id.editTextTransNumber);
  if (!TextUtils.isEmpty(mTransNumber)) {
    edtTransNumber.setText(mTransNumber);
  }
  btnTransNumber=(ImageButton)findViewById(R.id.buttonTransNumber);
  btnTransNumber.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      MoneyManagerOpenHelper helper=MoneyManagerOpenHelper.getInstance(CheckingAccountActivity.this);
      String query="String_Node_Str" + TableCheckingAccount.TRANSACTIONNUMBER + "String_Node_Str"+ new TableCheckingAccount().getSource()+ "String_Node_Str"+ TableCheckingAccount.ACCOUNTID+ "String_Node_Str";
      Cursor cursor=helper.getReadableDatabase().rawQuery(query,new String[]{Integer.toString(mAccountId)});
      if (cursor != null && cursor.moveToFirst()) {
        String transNumber=cursor.getString(0);
        if (TextUtils.isEmpty(transNumber)) {
          transNumber="String_Node_Str";
        }
        if ((!TextUtils.isEmpty(transNumber)) && TextUtils.isDigitsOnly(transNumber)) {
          try {
            edtTransNumber.setText(Long.toString(Long.parseLong(transNumber) + 1));
          }
 catch (          Exception e) {
            Log.e(LOGCAT,e.getMessage());
          }
        }
        cursor.close();
      }
    }
  }
);
  edtNotes=(EditText)findViewById(R.id.editTextNotes);
  if (!(TextUtils.isEmpty(mNotes))) {
    edtNotes.setText(mNotes);
  }
  refreshTransCode();
  refreshPayeeName();
  refreshCategoryName();
}