package safeluck.drive.evaluation.DB.lightdb
|
|
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.viewModelScope
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.launch
|
|
/**DriveJudge
|
* Created by lzw on 2021/1/15. 09:46:49
|
* 邮箱:632393724@qq.com
|
* All Rights Saved! Chongqing AnYun Tech co. LTD
|
*/
|
class LightAnswersViewModel internal constructor(private val lightDefaultRepository: LightAnswersRepository): ViewModel() {
|
fun getQustion2Answer(quest_id:Int) =lightDefaultRepository.getLightAllQuestions(quest_id)
|
|
|
|
|
@ExperimentalCoroutinesApi
|
override fun onCleared() {
|
super.onCleared()
|
viewModelScope.cancel()
|
}
|
|
fun updateAnswerChoose(id: Int, i: Int) {
|
viewModelScope.launch {
|
lightDefaultRepository.updateAnswerChoose(id,i)
|
}
|
}
|
|
fun getAllAnswers() =lightDefaultRepository.getLightAllAnswers()
|
}
|