package Ġcom . f red rik bo gg . notes app . ui . main Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . lifecycle . Android ViewModel Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . f red rik bo gg . notes app . util . Event Ċ import Ġcom . f red rik bo gg . notes app . data . db . Folder Note Room Database Ċ import Ġcom . f red rik bo gg . notes app . data . db . repository . Folders Repository Ċ import Ġcom . f red rik bo gg . notes app . data . db . entity . Folder Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠMain Folders ViewModel ( app : ĠApplication ) Ġ: ĠAndroid ViewModel ( app ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġrepository : ĠFold ers Repository ĊĠĠĠ Ġval Ġall Folders : ĠLive Data < List < Folder >> ĊĊĠĠĠ Ġvar Ġselected Folder Id Ġ= ĠMutable LiveData < Event < String >>() ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfolder Notes Dao Ġ= ĠFolder Note Room Database . get Database ( app ). folders Dao () ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠFold ers Repository ( folder Notes Dao ) ĊĠĠĠĠĠĠĠ Ġall Folders Ġ= Ġrepository . all Folders ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdefault Folder Selected () Ġ{ ĊĠĠĠĠĠĠĠ Ġselected Folder Id . value Ġ= ĠEvent ("") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfolder Selected ( folder : ĠFolder ) Ġ{ ĊĠĠĠĠĠĠĠ Ġselected Folder Id . value Ġ= ĠEvent ( folder . id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġinsert Folder () Ġ= ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠ Ġrepository . insert Folder ( Folder ()) ĊĠĠĠ Ġ} Ċ } ĊĊĊ