- if (amount.isEmpty()) {
- if (acc.isAmountSet())
- significantChange = true;
- acc.resetAmount();
- acc.setAmountValid(true);
- }
- else {
- try {
- amount = amount.replace(decimalSeparator, decimalDot);
- final float parsedAmount = Float.parseFloat(amount);
- if (!acc.isAmountSet() || !Misc.equalFloats(parsedAmount, acc.getAmount()))
- significantChange = true;
- acc.setAmount(parsedAmount);
- acc.setAmountValid(true);
- }
- catch (NumberFormatException e) {
- Logger.debug("new-trans", String.format(
- "assuming amount is not set due to number format exception. " +
- "input was '%s'", amount));
- if (acc.isAmountValid())
- significantChange = true;
- acc.resetAmount();
- acc.setAmountValid(false);
- }
- final String curr = String.valueOf(b.currency.getText());
- final String currValue;
- if (curr.equals(b.currency.getContext()
- .getResources()
- .getString(R.string.currency_symbol)) || curr.isEmpty())
- currValue = null;
- else
- currValue = curr;
-
- if (!significantChange && !Misc.equalStrings(acc.getCurrency(), currValue))
- significantChange = true;
- acc.setCurrency(currValue);
- }
+ if (acc.setAndCheckAmountText(Misc.nullIsEmpty(amount)))
+ significantChange = true;
+ displayAmountValidity(!acc.isAmountSet() || acc.isAmountValid());
+
+ final String curr = String.valueOf(b.currency.getText());
+ final String currValue;
+ if (curr.equals(b.currency.getContext()
+ .getResources()
+ .getString(R.string.currency_symbol)) || curr.isEmpty())
+ currValue = null;
+ else
+ currValue = curr;
+
+ if (!significantChange && !Misc.equalStrings(acc.getCurrency(), currValue))
+ significantChange = true;
+ acc.setCurrency(currValue);