Skip to content

Instantly share code, notes, and snippets.

@vprabhu
Created May 23, 2018 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vprabhu/b0f3b3d1903d105bb5d92df1364e4725 to your computer and use it in GitHub Desktop.
Save vprabhu/b0f3b3d1903d105bb5d92df1364e4725 to your computer and use it in GitHub Desktop.
class TodoListViewModel : AndroidViewModel {
private var mTodoTaskList : LiveData<List<TodoTask>> ?= null
constructor(application: Application) : super(application) {
val appDatabase : AppDatabase? = AppDatabase.getInstance(this.getApplication())
mTodoTaskList = appDatabase?.todoTaskDao()?.getallTasks()
}
fun getAllTasksFromViewModel() : LiveData<List<TodoTask>>? {
return mTodoTaskList
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment