mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-03-31 23:22:15 +00:00
Do not run setMarkdown on I/O thread
This commit is contained in:
parent
d3eb61e0e4
commit
8a23d1da58
@ -10,6 +10,7 @@ import com.topjohnwu.magisk.di.ServiceLocator
|
|||||||
import com.topjohnwu.magisk.view.MagiskDialog
|
import com.topjohnwu.magisk.view.MagiskDialog
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@ -23,12 +24,13 @@ abstract class MarkDownDialog : DialogEvent() {
|
|||||||
val view = LayoutInflater.from(context).inflate(R.layout.markdown_window_md2, null)
|
val view = LayoutInflater.from(context).inflate(R.layout.markdown_window_md2, null)
|
||||||
setView(view)
|
setView(view)
|
||||||
val tv = view.findViewById<TextView>(R.id.md_txt)
|
val tv = view.findViewById<TextView>(R.id.md_txt)
|
||||||
(ownerActivity as BaseActivity).lifecycleScope.launch(Dispatchers.IO) {
|
(ownerActivity as BaseActivity).lifecycleScope.launch {
|
||||||
try {
|
try {
|
||||||
ServiceLocator.markwon.setMarkdown(tv, getMarkdownText())
|
val text = withContext(Dispatchers.IO) { getMarkdownText() }
|
||||||
|
ServiceLocator.markwon.setMarkdown(tv, text)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
tv.post { tv.setText(R.string.download_file_error) }
|
tv.setText(R.string.download_file_error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user