+ currencyObserver = currency -> {
+ setCurrency(currency);
+ adapter.checkTransactionSubmittable();
+ };
+
+ currencyGapObserver =
+ hasGap -> updateCurrencyPositionAndPadding(Data.currencySymbolPosition.getValue(),
+ hasGap);
+
+ currencyPositionObserver =
+ position -> updateCurrencyPositionAndPadding(position, Data.currencyGap.getValue());
+
+ showCurrencyObserver = showCurrency -> {
+ if (showCurrency) {
+ tvCurrency.setVisibility(View.VISIBLE);
+ }
+ else {
+ tvCurrency.setVisibility(View.GONE);
+ item.setCurrency(null);
+ }
+ };
+
+ commentObserver = comment -> {
+ final View focusedView = tvComment.findFocus();
+ tvComment.setTypeface(null,
+ (focusedView == tvComment) ? Typeface.NORMAL : Typeface.ITALIC);
+ tvComment.setVisibility(
+ ((focusedView != tvComment) && TextUtils.isEmpty(comment)) ? View.INVISIBLE
+ : View.VISIBLE);
+ };
+
+ showCommentsObserver = show -> {
+ final View amountLayout = itemView.findViewById(R.id.amount_layout);
+ ConstraintLayout.LayoutParams amountLayoutParams =
+ (ConstraintLayout.LayoutParams) amountLayout.getLayoutParams();
+ ConstraintLayout.LayoutParams accountParams =
+ (ConstraintLayout.LayoutParams) tvAccount.getLayoutParams();
+ if (show) {
+ accountParams.endToStart = ConstraintLayout.LayoutParams.UNSET;
+ accountParams.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
+
+ amountLayoutParams.topToTop = ConstraintLayout.LayoutParams.UNSET;
+ amountLayoutParams.topToBottom = tvAccount.getId();
+
+ commentLayout.setVisibility(View.VISIBLE);
+ }
+ else {
+ accountParams.endToStart = amountLayout.getId();
+ accountParams.endToEnd = ConstraintLayout.LayoutParams.UNSET;
+
+ amountLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET;
+ amountLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
+
+ commentLayout.setVisibility(View.GONE);
+ }
+
+ tvAccount.setLayoutParams(accountParams);
+ amountLayout.setLayoutParams(amountLayoutParams);
+
+ transactionCommentLayout.setVisibility(show ? View.VISIBLE : View.GONE);
+ };
+
+ amountValidityObserver = valid -> {
+ tvAmount.setCompoundDrawablesRelativeWithIntrinsicBounds(
+ valid ? 0 : R.drawable.ic_error_outline_black_24dp, 0, 0, 0);
+ tvAmount.setMinEms(valid ? 4 : 5);