File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
app/src/main/java/com/osfans/trime/ui/main Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,25 @@ package com.osfans.trime.ui.main
66
77import androidx.lifecycle.MutableLiveData
88import androidx.lifecycle.ViewModel
9+ import androidx.lifecycle.viewModelScope
910import com.osfans.trime.daemon.RimeDaemon
1011import com.osfans.trime.daemon.RimeSession
12+ import kotlinx.coroutines.Dispatchers
13+ import kotlinx.coroutines.launch
1114
1215class MainViewModel : ViewModel () {
1316 val toolbarTitle = MutableLiveData <String >()
1417
1518 val topOptionsMenu = MutableLiveData <Boolean >()
1619
17- val rime: RimeSession = RimeDaemon .createSession(javaClass.name)
20+ private lateinit var _rime : RimeSession
21+ val rime: RimeSession get() = _rime
22+
23+ init {
24+ viewModelScope.launch(Dispatchers .Default ) {
25+ _rime = RimeDaemon .createSession(javaClass.name)
26+ }
27+ }
1828
1929 val restartBackgroundSyncWork = MutableLiveData (false )
2030
You can’t perform that action at this time.
0 commit comments