Ejemplo n.º 1
0
    private void initializeAmount(TransactionUIModel transaction) {
      IconTextView transactionIcon =
          (IconTextView) itemView.findViewById(R.id.transactionTypeImage);

      transactionIcon.setText(
          transaction.isIncome()
              ? context.getText(R.string.basketFill)
              : context.getText(R.string.basketUnFill));

      TextView amountView = (TextView) itemView.findViewById(R.id.transactionAmount);
      amountView.setText(
          CurrencyUtil.formatCurrency(transaction.getAmount(), transaction.getCurrencyType()));
    }
Ejemplo n.º 2
0
 @Override
 public void onTransactionAdded(
     TransactionUIModel transaction, TransactionUIModel parentTransaction) {
   int index = findTransactionIndex(parentTransaction.getId());
   transactions.add(++index, transaction);
   notifyItemInserted(index);
 }
Ejemplo n.º 3
0
 @Override
 public void onTransactionsUpdated(TransactionUIModel transaction) {
   int index = findTransactionIndex(transaction.getId());
   if (index > 0) {
     transactions.get(index).populateWith(transaction);
     notifyItemChanged(index);
   }
 }
Ejemplo n.º 4
0
    private void saveGoalTransaction(GoalTransactionUIModel goalTransactionUIModel) {
      try {
        TransactionUIModel transactionUIModel = goalTransactionUIModel.getTransaction();
        Transaction transaction = transactionDao.queryForId(transactionUIModel.getId());

        GoalTransaction goalTransaction = new GoalTransaction(transaction);
        goalTransactionDao.create(goalTransaction);

        transaction.setGoalTransaction(goalTransaction);
        transaction.setAmount(transactionUIModel.getAmount());
        transactionDao.update(transaction);

        transactionsUpdateListener.onTransactionsUpdated(transactionUIModel);
      } catch (SQLException e) {
        Log.e(TAG, "Error updating goal transaction", e);
      }
    }
Ejemplo n.º 5
0
    private void initializeImageButton(final TransactionUIModel transaction) {
      IconTextView goalImage = (IconTextView) itemView.findViewById(R.id.goalTransactionButton);

      if (transaction.getGoalTransaction() != null || transaction.isIncome()) {
        goalImage.setVisibility(View.GONE);
      } else {
        goalImage.setVisibility(View.VISIBLE);
      }

      goalImage.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              showGoalTransactionDialog(transaction);
            }
          });
    }
Ejemplo n.º 6
0
 private void initializeDate(TransactionUIModel transaction) {
   TextView date = (TextView) itemView.findViewById(R.id.transactionDate);
   DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(DATE_FORMAT);
   DateTimeParser parser = dateTimeFormatter.getParser();
   DateTimePrinter printer = dateTimeFormatter.getPrinter();
   DateTimeFormatter formatter =
       new DateTimeFormatterBuilder().append(printer, parser).toFormatter();
   date.setText(transaction.getMessageDate().toString(formatter));
 }
Ejemplo n.º 7
0
    private void splitTransaction(
        TransactionUIModel transaction, GoalTransactionUIModel goalTransaction) {
      try {
        TransactionUIModel parentTransaction = goalTransaction.getTransaction();
        Double rest =
            new BigDecimal(transaction.getAmount())
                .add(new BigDecimal(parentTransaction.getAmount()).negate())
                .doubleValue();

        saveGoalTransaction(goalTransaction);

        Transaction clone = transactionDao.queryForId(transaction.getId()).getClone();
        clone.setAmount(rest);
        transactionDao.create(clone);
        transactionsUpdateListener.onTransactionAdded(
            ConvertUtil.convertToUIModel(clone), parentTransaction);
      } catch (SQLException e) {
        Log.e(TAG, "Error splitting transaction", e);
      }
    }
Ejemplo n.º 8
0
 private void initializeMassage(TransactionUIModel transaction) {
   TextView message = (TextView) itemView.findViewById(R.id.transactionMessage);
   message.setText(transaction.getMessage());
 }