~fchaillo/financisto/financisto_remove_GreenDroid

« back to all changes in this revision

Viewing changes to src/ru/orangesoftware/financisto/utils/Utils.java

  • Committer: Fabien Chaillou
  • Date: 2013-01-13 00:25:45 UTC
  • mfrom: (447.2.19 FinancistoSQLite)
  • Revision ID: fabien.chaillou@gmail.com-20130113002545-5k8oid465p3tqobm
Merge with Master

Show diffs side-by-side

added added

removed removed

Lines of Context:
288
288
 
289
289
    public void setAmountText(TextView totalText, Total total) {
290
290
        if (total.showAmount) {
291
 
            setAmountTextWithBothAmountAndBalance(totalText, total);
 
291
            setAmountTextWithTwoAmounts(totalText, total.currency, total.amount, total.balance);
 
292
        } else if (total.showIncomeExpense) {
 
293
            setAmountTextWithTwoAmounts(totalText, total.currency, total.income, total.expenses);
292
294
        } else {
293
295
            setAmountText(totalText, total.currency, total.balance, false);
294
296
        }
295
297
    }
296
298
 
297
 
    private void setAmountTextWithBothAmountAndBalance(TextView textView, Total t) {
 
299
    private void setAmountTextWithTwoAmounts(TextView textView, Currency c, long amount1, long amount2) {
298
300
        SpannableStringBuilder sb = new SpannableStringBuilder();
299
 
        sb.append(Utils.amountToString(t.currency, t.amount, false));
 
301
        sb.append(Utils.amountToString(c, amount1, false));
300
302
        int x = sb.length();
301
 
        sb.setSpan(getAmountSpan(context, t.amount), 0, x, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
 
303
        sb.setSpan(getAmountSpan(context, amount1), 0, x, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
302
304
        sb.append(" | ");
303
 
        sb.append(Utils.amountToString(t.currency, t.balance, false));
304
 
        sb.setSpan(getAmountSpan(context, t.balance), x+3, sb.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
 
305
        sb.append(Utils.amountToString(c, amount2, false));
 
306
        sb.setSpan(getAmountSpan(context, amount2), x+3, sb.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
305
307
        textView.setText(sb, TextView.BufferType.NORMAL);
306
308
    }
307
309