From 85f9fe59f684703b78a1c3294c9d777d0742a26e Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Feb 2020 16:59:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/widget/font/FontAdapter.kt | 4 ++-- .../io/legado/app/ui/widget/font/FontSelectDialog.kt | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt index f7c73030a..f2724abcd 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt @@ -20,7 +20,7 @@ class FontAdapter(context: Context, val callBack: CallBack) : tv_font.typeface = typeface tv_font.text = item.name this.onClick { callBack.onClick(item) } - if (item.name == callBack.curFilePath().substringAfterLast(File.separator)) { + if (item.name == callBack.curFilePath.substringAfterLast(File.separator)) { iv_checked.visible() } else { iv_checked.invisible() @@ -38,6 +38,6 @@ class FontAdapter(context: Context, val callBack: CallBack) : interface CallBack { fun onClick(file: File) - fun curFilePath(): String + val curFilePath: String } } \ No newline at end of file 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 6732bf985..f72484338 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 @@ -209,7 +209,7 @@ class FontSelectDialog : BaseDialogFragment(), launch(IO) { file.copyTo(FileUtils.createFileIfNotExist(fontFolder, file.name), true) .absolutePath.let { path -> - if (callBack?.curFontPath != path) { + if (curFilePath != path) { withContext(Main) { callBack?.selectFile(path) } @@ -219,10 +219,6 @@ class FontSelectDialog : BaseDialogFragment(), } } - override fun curFilePath(): String { - return callBack?.curFontPath ?: "" - } - override fun onFilePicked(requestCode: Int, currentPath: String) { when (requestCode) { fontFolderRequestCode -> { @@ -256,13 +252,15 @@ class FontSelectDialog : BaseDialogFragment(), } private fun onDefaultFontChange() { - if (curFilePath() == "") { + if (curFilePath == "") { postEvent(EventBus.UP_CONFIG, true) } else { callBack?.selectFile("") } } + override val curFilePath: String get() = callBack?.curFontPath ?: "" + private val callBack: CallBack? get() = (parentFragment as? CallBack) ?: (activity as? CallBack)