+ public @NotNull String getAmountText() {
+ return amountText;
+ }
+ public void setAmountText(@NotNull String amountText) {
+ this.amountText = amountText;
+ }
+ public boolean setAndCheckAmountText(@NotNull String amountText) {
+ String amtText = amountText.trim();
+ this.amountText = amtText;
+
+ boolean significantChange = false;
+
+ if (amtText.isEmpty()) {
+ if (amountSet) {
+ significantChange = true;
+ }
+ resetAmount();
+ }
+ else {
+ try {
+ amtText = amtText.replace(Data.getDecimalSeparator(), Data.decimalDot);
+ final float parsedAmount = Float.parseFloat(amtText);
+ if (!amountSet || !amountValid || !Misc.equalFloats(parsedAmount, amount))
+ significantChange = true;
+ amount = parsedAmount;
+ amountSet = true;
+ amountValid = true;
+ }
+ catch (NumberFormatException e) {
+ Logger.debug("new-trans", String.format(
+ "assuming amount is not set due to number format exception. " +
+ "input was '%s'", amtText));
+ if (amountValid) // it was valid and now it's not
+ significantChange = true;
+ amountValid = false;
+ }
+ }
+
+ return significantChange;
+ }