- hasGap);
-
- currencyPositionObserver =
- position -> updateCurrencyPositionAndPadding(position, Data.currencyGap.getValue());
-
- showCurrencyObserver = showCurrency -> {
- if (showCurrency) {
- b.currency.setVisibility(View.VISIBLE);
- b.currencyButton.setVisibility(View.VISIBLE);
- String defaultCommodity = mProfile.getDefaultCommodity();
- item.setCurrency(
- (defaultCommodity == null) ? null : Currency.loadByName(defaultCommodity));
- }
- else {
- b.currency.setVisibility(View.GONE);
- b.currencyButton.setVisibility(View.GONE);
- item.setCurrency(null);
+ hasGap));
+
+ Data.currencySymbolPosition.observe(activity,
+ position -> updateCurrencyPositionAndPadding(position,
+ Data.currencyGap.getValue()));
+
+ adapter.model.getShowCurrency()
+ .observe(activity, showCurrency -> {
+ if (showCurrency) {
+ b.currency.setVisibility(View.VISIBLE);
+ b.currencyButton.setVisibility(View.VISIBLE);
+ b.currency.setText(mProfile.getDefaultCommodity());
+ }
+ else {
+ b.currency.setVisibility(View.GONE);
+ b.currencyButton.setVisibility(View.GONE);
+ b.currency.setText(null);
+ }
+ });
+
+ adapter.model.getShowComments()
+ .observe(activity, show -> {
+ ConstraintLayout.LayoutParams amountLayoutParams =
+ (ConstraintLayout.LayoutParams) b.amountLayout.getLayoutParams();
+ ConstraintLayout.LayoutParams accountParams =
+ (ConstraintLayout.LayoutParams) b.accountRowAccName.getLayoutParams();
+
+ if (show) {
+ accountParams.endToStart = ConstraintLayout.LayoutParams.UNSET;
+ accountParams.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
+
+ amountLayoutParams.topToTop = ConstraintLayout.LayoutParams.UNSET;
+ amountLayoutParams.topToBottom = b.accountRowAccName.getId();
+
+ b.commentLayout.setVisibility(View.VISIBLE);
+ }
+ else {
+ accountParams.endToStart = b.amountLayout.getId();
+ accountParams.endToEnd = ConstraintLayout.LayoutParams.UNSET;
+
+ amountLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET;
+ amountLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
+
+ b.commentLayout.setVisibility(View.GONE);
+ }
+
+ b.accountRowAccName.setLayoutParams(accountParams);
+ b.amountLayout.setLayoutParams(amountLayoutParams);
+
+ b.transactionCommentLayout.setVisibility(show ? View.VISIBLE : View.GONE);
+ });
+ }
+ public void checkAmountValid(String s) {
+ boolean valid = true;
+ try {
+ if (s.length() > 0) {
+ float ignored = Float.parseFloat(s.replace(decimalSeparator, decimalDot));