]> git.ktnx.net Git - mobile-ledger.git/commitdiff
avoid dataSync when updating entered amount format on losing focus
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 7 Mar 2021 09:42:50 +0000 (11:42 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 7 Mar 2021 09:42:50 +0000 (11:42 +0200)
no back-end data is changed, only the formatted text in the UI

app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java

index 0e2c947517140719fa3d9934e7e5bca734ba6953..6df1b5406cac95c88d9f25565f4374b4764cf2b6 100644 (file)
@@ -125,8 +125,16 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
                         String input = String.valueOf(b.accountRowAccAmounts.getText());
                         input = input.replace(decimalSeparator, decimalDot);
                         final String newText = String.format("%4.2f", Float.parseFloat(input));
-                        if (!newText.equals(input))
-                            b.accountRowAccAmounts.setText(newText);
+                        if (!newText.equals(input)) {
+                            boolean wasSyncingData = syncingData;
+                            syncingData = true;
+                            try {
+                                b.accountRowAccAmounts.setText(newText);
+                            }
+                            finally {
+                                syncingData = wasSyncingData;
+                            }
+                        }
                     }
                     catch (NumberFormatException ex) {
                         // ignored