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 6b343b4e4..c21503ce0 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 @@ -21,6 +21,7 @@ class FontSelectDialog(context: Context) : FontAdapter.CallBack { Environment.getExternalStorageDirectory().absolutePath + File.separator + "Fonts" private lateinit var adapter: FontAdapter private var builder: AlertBuilder + private var dialog: DialogInterface? = null @SuppressLint("InflateParams") private var view: View = LayoutInflater.from(context).inflate(R.layout.dialog_font_select, null) var curPath: String? = null @@ -38,7 +39,7 @@ class FontSelectDialog(context: Context) : FontAdapter.CallBack { } fun show() { - builder.show() + dialog = builder.show() } private fun initData() = with(view) { @@ -71,6 +72,7 @@ class FontSelectDialog(context: Context) : FontAdapter.CallBack { override fun onClick(file: File) { selectFile?.invoke(file.absolutePath) + dialog?.dismiss() } override fun curFilePath(): String {