コード例 #1
0
  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);
      }
    }
  }
コード例 #2
0
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Activity activity = getActivity();
    application = (WalletApplication) activity.getApplication();
    prefs = PreferenceManager.getDefaultSharedPreferences(activity);

    application.getWallet().addEventListener(walletEventListener);
  }
コード例 #3
0
  public void updateView() {
    viewBalance.setAmount(application.getWallet().getBalance(BalanceType.ESTIMATED));

    getLoaderManager().restartLoader(0, null, this);
  }
コード例 #4
0
  @Override
  public void onDestroy() {
    application.getWallet().removeEventListener(walletEventListener);

    super.onDestroy();
  }