Example #1
0
  private static final class SimpleTransactionViewHolder extends TransactionViewHolder {

    private final MoneyFormatter moneyFormatter = MoneyFormatter.withoutPlusPrefix();
    private final TextView hintTextView;

    private SimpleTransactionViewHolder(View root) {
      super(root);
      this.hintTextView = Views.find(root, R.id.hintTextView);
    }

    @Override
    public void updateViewFor(Transaction transaction) {
      super.updateViewFor(transaction);
      hintTextView.setText(ListViewUtil.getHint(transaction.getDirection()));
    }

    @Override
    protected String formatValue(Transaction transaction) {
      if (transaction.isFinancial()) {
        return moneyFormatter.format(new BigDecimal(transaction.getValue()));
      } else {
        return transaction.getValue();
      }
    }

    @Override
    protected BigDecimal getAmountForColoring(Transaction transaction) {
      return transaction.getDirection() == WITHDRAWAL ? Constants.MINUS_ONE : BigDecimal.ONE;
    }
  }
Example #2
0
 @Override
 protected String formatValue(Transaction transaction) {
   if (transaction.isFinancial()) {
     return moneyFormatter.format(new BigDecimal(transaction.getValue()));
   } else {
     return transaction.getValue();
   }
 }
Example #3
0
  private static final class GroupTransactionViewHolder extends TransactionViewHolder {

    private final MoneyFormatter moneyFormatter = MoneyFormatter.withPlusPrefix();

    private GroupTransactionViewHolder(View root) {
      super(root);
    }

    @Override
    protected String formatValue(Transaction transaction) {
      return moneyFormatter.format(getAmountForColoring(transaction));
    }

    @Override
    protected BigDecimal getAmountForColoring(Transaction transaction) {
      BigDecimal absAmount = new BigDecimal(transaction.getValue());
      return transaction.getDirection() == WITHDRAWAL ? absAmount.negate() : absAmount;
    }
  }
Example #4
0
 @Override
 protected String formatValue(Transaction transaction) {
   return moneyFormatter.format(getAmountForColoring(transaction));
 }