private List<CoinType> getCoinsTypes(Bundle args) { ArrayList<String> coinIds = args.getStringArrayList(Constants.ARG_MULTIPLE_COIN_IDS); if (coinIds != null) { List<CoinType> coinTypes = new ArrayList<CoinType>(); for (String id : coinIds) { coinTypes.add(CoinID.typeFromId(id)); } return coinTypes; } else { return Constants.DEFAULT_COINS; } }
private AbstractAddress getDepositAddress(Uri uri) { AbstractAddress address; final List<String> pathSegments = getPathSegments(uri); try { address = CoinID.typeFromId(pathSegments.get(0)).newAddress(pathSegments.get(1)); } catch (AddressMalformedException e) { throw new IllegalArgumentException(e); } return address; }
@Override public void bindView(final View view, final Context context, final Cursor cursor) { final String label = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_LABEL)); final String coinId = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_COIN_ID)); final String addressStr = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS)); CoinType type = CoinID.typeFromId(coinId); final ViewGroup viewGroup = (ViewGroup) view; final TextView labelView = (TextView) viewGroup.findViewById(R.id.address_book_row_label); labelView.setText(label); final TextView addressView = (TextView) viewGroup.findViewById(R.id.address_book_row_address); try { addressView.setText(GenericUtils.addressSplitToGroupsMultiline(type.newAddress(addressStr))); } catch (AddressMalformedException e) { ACRA.getErrorReporter().handleSilentException(e); addressView.setText(addressStr); } }
@Override public void onCoinSelection(Bundle args) { ArrayList<String> ids = args.getStringArrayList(Constants.ARG_MULTIPLE_COIN_IDS); // For new we add only one coin at a time selectedCoin = CoinID.typeFromId(ids.get(0)); if (wallet.isAccountExists(selectedCoin)) { new AlertDialog.Builder(this) .setTitle(getString(R.string.coin_already_added_title, selectedCoin.getName())) .setMessage(R.string.coin_already_added) .setPositiveButton(R.string.button_ok, null) .create().show(); return; } showAddCoinDialog(); }
public static ExchangeEntry getExchangeEntry(@Nonnull final Cursor cursor) { final int status = getStatus(cursor); CoinType depositType = CoinID.typeFromId(cursor.getString(cursor.getColumnIndexOrThrow(KEY_DEPOSIT_COIN_ID))); AbstractAddress depositAddress; try { depositAddress = depositType.newAddress(cursor.getString(cursor.getColumnIndexOrThrow(KEY_DEPOSIT_ADDRESS))); } catch (AddressMalformedException e) { // Should never happen throw new RuntimeException(e); } Value depositAmount = depositType.value(cursor.getLong(cursor.getColumnIndexOrThrow(KEY_DEPOSIT_AMOUNT_UNIT))); String depositTxId = cursor.getString(cursor.getColumnIndexOrThrow(KEY_DEPOSIT_TXID)); AbstractAddress withdrawAddress; Value withdrawAmount; String withdrawTxId; try { CoinType withdrawType = CoinID.typeFromId(cursor.getString(cursor.getColumnIndexOrThrow(KEY_WITHDRAW_COIN_ID))); withdrawAddress = withdrawType.newAddress(cursor.getString(cursor.getColumnIndexOrThrow(KEY_WITHDRAW_ADDRESS))); withdrawAmount = withdrawType.value(cursor.getLong(cursor.getColumnIndexOrThrow(KEY_WITHDRAW_AMOUNT_UNIT))); withdrawTxId = cursor.getString(cursor.getColumnIndexOrThrow(KEY_WITHDRAW_TXID)); } catch (Exception e) { withdrawAddress = null; withdrawAmount = null; withdrawTxId = null; } return new ExchangeEntry(status, depositAddress, depositAmount, depositTxId, withdrawAddress, withdrawAmount, withdrawTxId); }
private static CoinType getType(Protos.WalletPocket proto) throws UnreadableWalletException { try { return CoinID.typeFromId(proto.getNetworkIdentifier()); } catch (IllegalArgumentException e) { throw new UnreadableWalletException("Unknown network parameters ID " + proto.getNetworkIdentifier()); } }
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final CoinType type = CoinID.typeFromId(args.getString(KEY_COIN_ID)); final AbstractAddress address = (AbstractAddress) args.getSerializable(KEY_ADDRESS); final String suggestedAddressLabel = args.getString(KEY_SUGGESTED_ADDRESS_LABEL);
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null && getArguments().containsKey(Constants.ARG_COIN_ID)) { type = CoinID.typeFromId(getArguments().getString(Constants.ARG_COIN_ID)); } else { type = BitcoinMain.get(); } contentUri = ExchangeRatesProvider.contentUriToLocal(context.getPackageName(), type.getSymbol(), false); defaultCurrency = config.getExchangeCurrencyCode(); config.registerOnSharedPreferenceChangeListener(this); adapter = new ExchangeRatesAdapter(context); setListAdapter(adapter); loaderManager.initLoader(ID_RATE_LOADER, null, rateLoaderCallbacks); }
final CoinType type = CoinID.typeFromId(getArguments().getString(Constants.ARG_COIN_ID)); feeAmount.resetType(type);
CoinType coinType; try { coinType = CoinID.typeFromId(walletProto.getNetworkIdentifier()); } catch (IllegalArgumentException e) { throw new UnreadableWalletException("Unknown network parameters ID " + walletProto.getNetworkIdentifier());
CoinType coinType; try { coinType = CoinID.typeFromId(walletProto.getNetworkIdentifier()); } catch (IllegalArgumentException e) { throw new UnreadableWalletException("Unknown network parameters ID " + walletProto.getNetworkIdentifier());