public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) { if (data != null) { data.moveToFirst(); final Double exchangeRate = data.getDouble(data.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_EXCHANGE_RATE)); viewBalanceLocal.setVisibility(View.GONE); if (application.getWallet().getBalance(BalanceType.ESTIMATED).signum() > 0 && exchangeRate != null) { final String exchangeCurrency = prefs.getString( Constants.PREFS_KEY_EXCHANGE_CURRENCY, Constants.DEFAULT_EXCHANGE_CURRENCY); final BigInteger balance = application.getWallet().getBalance(BalanceType.ESTIMATED); final BigInteger valueLocal = new BigDecimal(balance).multiply(new BigDecimal(exchangeRate)).toBigInteger(); viewBalanceLocal.setVisibility(View.VISIBLE); viewBalanceLocal.setText( getString( R.string.wallet_balance_fragment_local_value, exchangeCurrency, WalletUtils.formatValue(valueLocal))); if (Constants.TEST) viewBalanceLocal.setPaintFlags( viewBalanceLocal.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } } }
@Override public boolean onContextItemSelected(final MenuItem item) { try { final AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); final Map<String, Object> map = (Map<String, Object>) getListView().getAdapter().getItem(menuInfo.position); final String address = (String) map.get("addr"); switch (item.getItemId()) { case R.id.wallet_addresses_context_archive: { MyRemoteWallet remoteWallet = application.getRemoteWallet(); if (remoteWallet == null) return true; remoteWallet.setTag(address, 2); application.saveWallet( new SuccessCallback() { @Override public void onSuccess() { EventListeners.invokeWalletDidChange(); } @Override public void onFail() {} }); return true; } case R.id.wallet_addresses_context_edit: { EditAddressBookEntryFragment.edit(getFragmentManager(), address.toString()); return true; } case R.id.wallet_addresses_context_show_qr: { final String uri = BitcoinURI.convertToBitcoinURI(address, null, null, null); final int size = (int) (256 * getResources().getDisplayMetrics().density); new QrDialog(activity, WalletUtils.getQRCodeBitmap(uri, size)).show(); return true; } case R.id.wallet_addresses_context_copy_to_clipboard: { AbstractWalletActivity.handleCopyToClipboard(activity, address.toString()); return true; } case R.id.wallet_addresses_context_default: { handleDefault(address); return true; } } } catch (Exception e) { e.printStackTrace(); } return false; }