コード例 #1
0
  public static void updateWidgets(
      final Context context,
      @Nonnull final AppWidgetManager appWidgetManager,
      @Nonnull final int[] appWidgetIds,
      @Nonnull final BigInteger balance) {
    final Configuration config =
        new Configuration(PreferenceManager.getDefaultSharedPreferences(context));
    final Spannable balanceStr =
        new SpannableString(
            GenericUtils.formatValue(balance, config.getBtcPrecision(), config.getBtcShift()));
    WalletUtils.formatSignificant(balanceStr, WalletUtils.SMALLER_SPAN);

    for (final int appWidgetId : appWidgetIds) {
      final RemoteViews views =
          new RemoteViews(context.getPackageName(), R.layout.wallet_balance_widget_content);
      views.setTextViewText(R.id.widget_wallet_prefix, config.getBtcPrefix());
      views.setTextViewText(R.id.widget_wallet_balance, balanceStr);
      views.setOnClickPendingIntent(
          R.id.widget_button_balance,
          PendingIntent.getActivity(context, 0, new Intent(context, WalletActivity.class), 0));
      views.setOnClickPendingIntent(
          R.id.widget_button_request,
          PendingIntent.getActivity(
              context, 0, new Intent(context, RequestCoinsActivity.class), 0));
      views.setOnClickPendingIntent(
          R.id.widget_button_send,
          PendingIntent.getActivity(context, 0, new Intent(context, SendCoinsActivity.class), 0));
      views.setOnClickPendingIntent(
          R.id.widget_button_send_qr,
          PendingIntent.getActivity(context, 0, new Intent(context, SendCoinsQrActivity.class), 0));

      appWidgetManager.updateAppWidget(appWidgetId, views);
    }
  }
コード例 #2
0
  private void updateView() {
    balance = application.getWallet().getBalance(BalanceType.ESTIMATED);

    if (adapter != null) {
      final int btcShift = config.getBtcShift();

      final BigInteger base = btcShift == 0 ? GenericUtils.ONE_BTC : GenericUtils.ONE_MBTC;

      adapter.setRateBase(base);
    }
  }