In the previous video, we added a taskTiming MutableLiveData object (exposed via a public LiveData object called timing).
That code should have gone before the init block. It doesn't cause a problem yet, but it will do later.
Lines 45 to 47 (in the video) need to be moved to before the init block
private val databaseCursor = MutableLiveData<Cursor>()
val cursor: LiveData<Cursor>
get() = databaseCursor
private val taskTiming = MutableLiveData<String>()
val timing: LiveData<String>
get() = taskTiming
init {
Log.d(TAG, "TaskTimerViewModel: created")
getApplication<Application>().contentResolver.registerContentObserver(TasksContract.CONTENT_URI,
true, contentObserver)
loadTasks()
}
In the code block above, lines 5 to 7 were after the init block. They need to be moved to before it.