+ row = itemView.findViewById(R.id.account_summary_row);
+ tvAccountName = itemView.findViewById(R.id.account_row_acc_name);
+ tvAccountAmounts = itemView.findViewById(R.id.account_row_acc_amounts);
+ expanderContainer = itemView.findViewById(R.id.account_expander_container);
+ expander = itemView.findViewById(R.id.account_expander);
+ accountExpanderContainer =
+ itemView.findViewById(R.id.account_row_amounts_expander_container);
+
+ itemView.setOnLongClickListener(this::onItemLongClick);
+ tvAccountName.setOnLongClickListener(this::onItemLongClick);
+ tvAccountAmounts.setOnLongClickListener(this::onItemLongClick);
+ expanderContainer.setOnLongClickListener(this::onItemLongClick);
+ expander.setOnLongClickListener(this::onItemLongClick);
+ row.setOnLongClickListener(this::onItemLongClick);
+
+ tvAccountName.setOnClickListener(v -> toggleAccountExpanded());
+ expanderContainer.setOnClickListener(v -> toggleAccountExpanded());
+ expander.setOnClickListener(v -> toggleAccountExpanded());
+ tvAccountAmounts.setOnClickListener(v -> toggleAmountsExpanded());
+ }
+ private void toggleAccountExpanded() {
+ if (!mAccount.hasSubAccounts())
+ return;
+ debug("accounts", "Account expander clicked");
+
+ // make sure we use the same object as the one in the allAccounts list
+ MobileLedgerProfile profile = mAccount.getProfile();
+ if (profile == null) {
+ return;
+ }
+ try (Locker ignored = profile.lockAccountsForWriting()) {
+ LedgerAccount realAccount = profile.locateAccount(mAccount.getName());
+ if (realAccount == null)
+ return;