use of de.schildbach.wallet.exchangerate.ExchangeRatesRepository in project bitcoin-wallet by bitcoin-wallet.
the class WalletBalanceWidgetProvider method onUpdate.
@Override
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
final PendingResult result = goAsync();
AsyncTask.execute(() -> {
final WalletApplication application = (WalletApplication) context.getApplicationContext();
final Coin balance = application.getWallet().getBalance(BalanceType.ESTIMATED);
final Configuration config = application.getConfiguration();
final ExchangeRatesRepository exchangeRatesRepository = ExchangeRatesRepository.get(application);
final ExchangeRateEntry exchangeRate = config.isEnableExchangeRates() ? exchangeRatesRepository.exchangeRateDao().findByCurrencyCode(config.getExchangeCurrencyCode()) : null;
updateWidgets(context, appWidgetManager, appWidgetIds, balance, exchangeRate != null ? exchangeRate.exchangeRate() : null);
result.finish();
});
}
use of de.schildbach.wallet.exchangerate.ExchangeRatesRepository in project bitcoin-wallet by bitcoin-wallet.
the class WalletBalanceWidgetProvider method onAppWidgetOptionsChanged.
@Override
public void onAppWidgetOptionsChanged(final Context context, final AppWidgetManager appWidgetManager, final int appWidgetId, final Bundle newOptions) {
if (newOptions != null)
log.info("app widget {} options changed: minWidth={}", appWidgetId, newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH));
final PendingResult result = goAsync();
AsyncTask.execute(() -> {
final WalletApplication application = (WalletApplication) context.getApplicationContext();
final Coin balance = application.getWallet().getBalance(BalanceType.ESTIMATED);
final Configuration config = application.getConfiguration();
final ExchangeRatesRepository exchangeRatesRepository = ExchangeRatesRepository.get(application);
final ExchangeRateEntry exchangeRate = config.isEnableExchangeRates() ? exchangeRatesRepository.exchangeRateDao().findByCurrencyCode(config.getExchangeCurrencyCode()) : null;
updateWidget(context, appWidgetManager, appWidgetId, newOptions, balance, exchangeRate != null ? exchangeRate.exchangeRate() : null);
result.finish();
});
}
Aggregations