package ajitsingh.com.expensemanager.presenter;

import android.widget.ArrayAdapter;

import java.util.Date;
import java.util.List;

import ajitsingh.com.expensemanager.database.ExpenseDatabaseHelper;
import ajitsingh.com.expensemanager.model.Expense;
import ajitsingh.com.expensemanager.view.ExpenseView;

import static ajitsingh.com.expensemanager.utils.DateUtil.getCurrentDateTime;

public class ExpensePresenter {

  private ExpenseDatabaseHelper database;
  private ExpenseView view;

  public ExpensePresenter(ExpenseDatabaseHelper expenseDatabaseHelper, ExpenseView view) {
    this.database = expenseDatabaseHelper;
    this.view = view;
  }

  public void addExpense() {
    Expense expense = new Expense(Long.valueOf(view.getAmount()), view.getType(), getCurrentDateTime());
    database.addExpense(expense);
  }

  public void setExpenseTypes() {
    List<String> expenseTypes = database.getExpenseTypes();
    ArrayAdapter<String> adapter = view.getExpenseTypeAdapter(expenseTypes);
    view.renderExpenseTypes(adapter);
  }
}

@@ -83,31 +83,8 @@
 r;%0A%0A
-import java.util.Date;%0A
 impo
@@ -349,20 +349,16 @@
 rentDate
-Time
 ;%0A%0Apubli
@@ -746,12 +746,8 @@
 Date
-Time
 ());

store current date instead of datetime in db as it will help to consolidate expenses in db itself