我最近开始在我的Android项目中使用kotlin协程,但我对它有一些问题。许多人会称其为代码气味。我正在使用MVP架构,其中协程在我的演示者中启动,如下所示: // WorklistPresenter.ktoverride fun loadWorklist() {protected fun launchAsync(block: suspend CoroutineSc
当涉及到Kotlin编程时,我是一个大新手。我对线程有基本的了解。 事情是这样的:我正在尝试在点击一个按钮后每秒更新一次我的TextView (在片段中)。我将按钮的onClick函数设置为包含10个协程的延迟(1000)调用。但我总是得到这样的错误: CalledFromWrongThreadException: Only Main Thread is allowed to change View
我可以通过存储库类中托管的retrofit.this代码从网络接收数据: val webService = AppModuleDO中的update方法suspend fun updateQuestions(list: List<Question>)
如果代码在我的viewModel中,我可以在viewModelScope.launch{}中运行挂起函数,我需要知道