From 70324bceb28a00b4a339fbb5a12eb657094f6f22 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 7 Mar 2021 11:42:50 +0200 Subject: [PATCH] avoid dataSync when updating entered amount format on losing focus no back-end data is changed, only the formatted text in the UI --- .../ui/new_transaction/NewTransactionItemHolder.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 -- 2.39.5