From: Damyan Ivanov Date: Sun, 10 Nov 2019 11:22:17 +0000 (+0200) Subject: NewTransItemHolder: prevent sync loops via model data observers X-Git-Tag: v0.11.0~90 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=2c0103e9c08cd9d86180321960bf422f0255a6ac;p=mobile-ledger.git NewTransItemHolder: prevent sync loops via model data observers when the data in the model is changed (e.g. in a reset operation) the new data needs to be sent to the UI without this causing data sync back to the model --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java index 031453c3..3198cc16 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java @@ -121,15 +121,33 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder dateObserver = date -> { if (syncingData) return; - tvDate.setText(item.getFormattedDate()); + syncingData = true; + try { + tvDate.setText(item.getFormattedDate()); + } + finally { + syncingData = false; + } }; descriptionObserver = description -> { if (syncingData) return; - tvDescription.setText(description); + syncingData = true; + try { + tvDescription.setText(description); + } + finally { + syncingData = false; + } }; hintObserver = hint -> { if (syncingData) return; - tvAmount.setHint(hint); + syncingData = true; + try { + tvAmount.setHint(hint); + } + finally { + syncingData = false; + } }; focusedAccountObserver = index -> { if ((index != null) && index.equals(getAdapterPosition())) {