Commit 6b2485ff by huangzhicong

修复启动时可能因为协程线程池未初始化导致崩溃的问题

parent 77210a24
......@@ -13,10 +13,8 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.maxrocky.nativeview.R
import com.maxrocky.nativeview.utils.dataStore
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
class StartFragment : Fragment() {
......@@ -38,7 +36,7 @@ class StartFragment : Fragment() {
urlEditText = view.findViewById(R.id.url)
button = view.findViewById(R.id.enter)
lifecycleScope.launch(Dispatchers.IO) {
lifecycleScope.launchWhenResumed {
val storageKey = stringPreferencesKey(STORAGE_URL)
context?.dataStore?.data?.map { it[storageKey] ?: "" }?.collect {
urlEditText.setText(it)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment