package keijumt.todoapp.addtask import android.databinding.ObservableField import keijumt.todoapp.BaseViewModel import keijumt.todoapp.data.db.entity.Task import keijumt.todoapp.data.repository.TaskRepository import keijumt.todoapp.databinding.SingleLiveEvent import java.util.* import javax.inject.Inject /** * タスク追加のViewModel * Created by matsumoto_k on 2018/03/06. */ class AddEditTaskViewModel @Inject constructor( val repository: TaskRepository ) : BaseViewModel() { val taskTitle = ObservableField<String>("") val taskDetails = ObservableField<String>("") val taskAddEvent = SingleLiveEvent<Void>() fun onClickSave() { val task = Task(taskTitle.get(), taskDetails.get(), Calendar.getInstance().timeInMillis, Calendar.getInstance().timeInMillis) repository.save(task) taskAddEvent.call() } }