private String getFormattedAccountBalance(Context context, Account account) { WhereStatementGenerator where = new WhereStatementGenerator(); where.addStatement(QueryAccountBills.ACCOUNTID, "=", account.getId()); String selection = where.getWhere(); AccountService service = new AccountService(context); Money total = service.loadBalance(selection); // format the amount CurrencyService currencyService = new CurrencyService(context); String summary = currencyService.getCurrencyFormatted(account.getCurrencyId(), total); return summary; }
@Override public void bindView(View view, Context context, Cursor cursor) { TextView txtColumn1 = (TextView) view.findViewById(R.id.textViewColumn1); TextView txtColumn2 = (TextView) view.findViewById(R.id.textViewColumn2); Core core = new Core(context); double total = cursor.getDouble(cursor.getColumnIndex("TOTAL")); String column1; String category = cursor.getString(cursor.getColumnIndex(ViewMobileData.Category)); if (!TextUtils.isEmpty(category)) { column1 = "<b>" + category + "</b>"; String subCategory = cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory)); if (!TextUtils.isEmpty(subCategory)) { column1 += " : " + subCategory; } } else { column1 = "<i>" + context.getString(R.string.empty_category); } txtColumn1.setText(Html.fromHtml(column1)); CurrencyService currencyService = new CurrencyService(mContext); txtColumn2.setText( currencyService.getCurrencyFormatted( currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(total))); if (total < 0) { txtColumn2.setTextColor( context.getResources().getColor(core.resolveIdAttribute(R.attr.holo_red_color_theme))); } else { txtColumn2.setTextColor( context.getResources().getColor(core.resolveIdAttribute(R.attr.holo_green_color_theme))); } // view.setBackgroundColor(core.resolveColorAttribute(cursor.getPosition() % 2 == 1 ? // R.attr.row_dark_theme : R.attr.row_light_theme)); }