- focusedAccountObserver = index -> {
- if ((index == null) || !index.equals(getAdapterPosition()) || itemView.hasFocus())
- return;
-
- switch (item.getType()) {
- case generalData:
- // bad idea - double pop-up, and not really necessary.
- // the user can tap the input to get the calendar
- //if (!tvDate.hasFocus()) tvDate.requestFocus();
- switch (item.getFocusedElement()) {
- case TransactionComment:
- b.transactionComment.setVisibility(View.VISIBLE);
- b.transactionComment.requestFocus();
- break;
- case Description:
- boolean focused = b.newTransactionDescription.requestFocus();
-// tvDescription.dismissDropDown();
- if (focused)
- Misc.showSoftKeyboard((NewTransactionActivity) b.getRoot()
- .getContext());
- break;
- }
- break;
- case transactionRow:
- switch (item.getFocusedElement()) {
- case Amount:
- b.accountRowAccAmounts.requestFocus();
- break;
- case Comment:
- b.comment.setVisibility(View.VISIBLE);
- b.comment.requestFocus();
- break;
- case Account:
- boolean focused = b.accountRowAccName.requestFocus();
- b.accountRowAccName.dismissDropDown();
- if (focused)
- Misc.showSoftKeyboard((NewTransactionActivity) b.getRoot()
- .getContext());
- break;
- }
-
- break;
- }
- };
- accountCountObserver = count -> {
- final int adapterPosition = getAdapterPosition();
- final int layoutPosition = getLayoutPosition();
- Logger.debug("holder",
- String.format(Locale.US, "count=%d; pos=%d, layoutPos=%d [%s]", count,
- adapterPosition, layoutPosition, item.getType()
- .toString()
- .concat(item.getType() ==
- ItemType.transactionRow
- ? String.format(Locale.US,
- "'%s'=%s",
- item.getAccount()
- .getAccountName(),
- item.getAccount()
- .isAmountSet()
- ? String.format(Locale.US,
- "%.2f",
- item.getAccount()
- .getAmount())
- : "unset") : "")));
- if (adapterPosition == count)
- b.accountRowAccAmounts.setImeOptions(EditorInfo.IME_ACTION_DONE);
- else
- b.accountRowAccAmounts.setImeOptions(EditorInfo.IME_ACTION_NEXT);
- };
-
- currencyObserver = currency -> {
- setCurrency(currency);
- adapter.checkTransactionSubmittable();
- };