From: Damyan Ivanov Date: Sun, 7 Mar 2021 09:42:50 +0000 (+0200) Subject: avoid dataSync when updating entered amount format on losing focus X-Git-Tag: v0.17.0~14 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=70324bceb28a00b4a339fbb5a12eb657094f6f22;p=mobile-ledger.git avoid dataSync when updating entered amount format on losing focus no back-end data is changed, only the formatted text in the UI --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java index 0e2c9475..6df1b540 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java @@ -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