@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null) { if (args.containsKey(Constants.ARG_ACCOUNT_ID)) { String accountId = args.getString(Constants.ARG_ACCOUNT_ID); pocket = checkNotNull(application.getAccount(accountId)); } if (args.containsKey(Constants.ARG_URI)) { try { processUri(args.getString(Constants.ARG_URI)); } catch (CoinURIParseException e) { // TODO handle more elegantly Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); ACRA.getErrorReporter().handleException(e); } } if (pocket == null) { List<WalletAccount> accounts = application.getAllAccounts(); if (accounts.size() > 0) pocket = accounts.get(0); if (pocket == null) { ACRA.getErrorReporter() .putCustomData("wallet-exists", application.getWallet() == null ? "no" : "yes"); Toast.makeText(getActivity(), R.string.no_such_pocket_error, Toast.LENGTH_LONG).show(); getActivity().finish(); return; } } checkNotNull(pocket, "No account selected"); } else { throw new RuntimeException("Must provide account ID or a payment URI"); } sendAmountType = pocket.getCoinType(); messageFactory = pocket.getCoinType().getMessagesFactory(); if (savedInstanceState != null) { address = (Address) savedInstanceState.getSerializable(STATE_ADDRESS); addressTypeCanChange = savedInstanceState.getBoolean(STATE_ADDRESS_CAN_CHANGE_TYPE); sendAmount = (Value) savedInstanceState.getSerializable(STATE_AMOUNT); sendAmountType = (CoinType) savedInstanceState.getSerializable(STATE_AMOUNT_TYPE); } updateBalance(); setHasOptionsMenu(true); mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer); String localSymbol = config.getExchangeCurrencyCode(); for (ExchangeRatesProvider.ExchangeRate rate : getRates(getActivity(), localSymbol)) { localRates.put(rate.currencyCodeId, rate.rate); } loaderManager.initLoader(ID_RATE_LOADER, null, rateLoaderCallbacks); loaderManager.initLoader(ID_RECEIVING_ADDRESS_LOADER, null, receivingAddressLoaderCallbacks); }
private void handleSendConfirm() { if (!everythingValid()) { // Sanity check log.error("Unexpected validity failure."); validateAmount(); validateAddress(); validateTxMessage(); return; } state = State.PREPARATION; updateView(); if (application.getWallet() != null) { onMakeTransaction(address, sendAmount, getTxMessage()); } }