Ejemplo n.º 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;
    }
  }
Ejemplo n.º 2
0
 @Override
 protected String formatValue(Transaction transaction) {
   if (transaction.isFinancial()) {
     return moneyFormatter.format(new BigDecimal(transaction.getValue()));
   } else {
     return transaction.getValue();
   }
 }
Ejemplo n.º 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;
    }
  }
Ejemplo n.º 4
0
 @Override
 protected String formatValue(Transaction transaction) {
   return moneyFormatter.format(getAmountForColoring(transaction));
 }