private boolean isAccountVisible(WalletAccount account) { return account != null && accountFragment != null && accountFragment.isVisible() && account.equals(accountFragment.getAccount()); }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { AvailableAccountsAdaptor.Entry entry = (AvailableAccountsAdaptor.Entry) parent.getSelectedItem(); if (entry.accountOrCoinType instanceof WalletAccount) { WalletAccount newSource = (WalletAccount) entry.accountOrCoinType; // If same account selected, do nothing if (newSource.equals(sourceAccount)) return; // If new source and destination are the same, swap accounts if (destinationAccount != null && destinationAccount.isType(newSource)) { // Swap accounts setDestinationSpinner(sourceAccount); setDestination(sourceAccount, false); } setSource(newSource, true); } else { // Should not happen as "source" is always an account throw new IllegalStateException("Unexpected class: " + entry.accountOrCoinType.getClass()); } }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { AvailableAccountsAdaptor.Entry entry = (AvailableAccountsAdaptor.Entry) parent.getSelectedItem(); if (entry.accountOrCoinType instanceof WalletAccount) { WalletAccount newDestination = (WalletAccount) entry.accountOrCoinType; // If same account selected, do nothing if (newDestination.equals(destinationAccount)) return; // If new destination and source are the same, swap accounts if (destinationAccount != null && sourceAccount.isType(newDestination)) { // Swap accounts setSourceSpinner(destinationAccount); setSource(destinationAccount, false); } setDestination(newDestination, true); } else if (entry.accountOrCoinType instanceof CoinType) { setDestination((CoinType) entry.accountOrCoinType, true); } else { // Should not happen throw new IllegalStateException("Unexpected class: " + entry.accountOrCoinType.getClass()); } }