コード例 #1
0
 private static RemoteViews updateWidgetFromAccount(
     Context context, int widgetId, int layoutId, Class providerClass, Account a) {
   RemoteViews updateViews = new RemoteViews(context.getPackageName(), layoutId);
   updateViews.setTextViewText(R.id.line1, a.title);
   AccountType type = AccountType.valueOf(a.type);
   if (type.isCard && a.cardIssuer != null) {
     CardIssuer cardIssuer = CardIssuer.valueOf(a.cardIssuer);
     updateViews.setImageViewResource(R.id.account_icon, cardIssuer.iconId);
   } else {
     updateViews.setImageViewResource(R.id.account_icon, type.iconId);
   }
   long amount = a.totalAmount;
   updateViews.setTextViewText(R.id.note, Utils.amountToString(a.currency, amount));
   Utils u = new Utils(context);
   int amountColor = u.getAmountColor(amount);
   updateViews.setTextColor(R.id.note, amountColor);
   addScrollOnClick(context, updateViews, widgetId, providerClass);
   addTapOnClick(context, updateViews);
   addButtonsClick(context, updateViews);
   saveAccountForWidget(context, widgetId, a.id);
   return updateViews;
 }