diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 1fba2ce2e..a0a4170d8 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -41,11 +41,11 @@ class FontSelectDialog : DialogFragment(), FontAdapter.CallBack { lateinit var job: Job private val fontFolderRequestCode = 35485 - private lateinit var adapter: FontAdapter private val fontFolder = App.INSTANCE.filesDir.absolutePath + File.separator + "Fonts" + File.separator override val coroutineContext: CoroutineContext get() = job + Main + private var adapter: FontAdapter? = null override fun onStart() { super.onStart() @@ -144,7 +144,7 @@ class FontSelectDialog : DialogFragment(), pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex()) }?.let { withContext(Main) { - adapter.setItems(it.toList()) + adapter?.setItems(it.toList()) } } } catch (e: Exception) { @@ -161,7 +161,7 @@ class FontSelectDialog : DialogFragment(), file.listFiles { pathName -> pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex()) }?.let { - adapter.setItems(it.toList()) + adapter?.setItems(it.toList()) } } catch (e: Exception) { toast(e.localizedMessage ?: "")