From c2df639f949a2ebdf0333bc96814b37240b37604 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 3 Jan 2020 17:07:32 +0800 Subject: [PATCH] up --- .../app/ui/book/read/config/ReadStyleDialog.kt | 15 ++++++++++----- .../legado/app/ui/widget/font/FontSelectDialog.kt | 10 +++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index e19231b4a..3bc5060b0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -20,17 +20,14 @@ import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.book.read.Help import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.widget.font.FontSelectDialog -import io.legado.app.utils.getPrefInt -import io.legado.app.utils.postEvent -import io.legado.app.utils.progressAdd -import io.legado.app.utils.putPrefInt +import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_book_read.* import kotlinx.android.synthetic.main.dialog_read_book_style.* import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onLongClick -class ReadStyleDialog : DialogFragment() { +class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { override fun onStart() { super.onStart() @@ -263,4 +260,12 @@ class ReadStyleDialog : DialogFragment() { else -> bg0.borderColor = requireContext().accentColor } } + + override val curFontPath: String + get() = requireContext().getPrefString(PreferKey.readBookFont) ?: "" + + override fun selectFile(path: String) { + requireContext().putPrefString(PreferKey.readBookFont, path) + postEvent(Bus.UP_CONFIG, true) + } } \ 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 4d726d973..7b7a97e9b 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 @@ -141,13 +141,13 @@ class FontSelectDialog : DialogFragment(), file.absolutePath.let { val pf = parentFragment if (pf is CallBack) { - if (it != pf.curPath) { + if (it != pf.curFontPath) { pf.selectFile(it) } } val activity = activity if (activity is CallBack) { - if (it != activity.curPath) { + if (it != activity.curFontPath) { activity.selectFile(it) } } @@ -158,11 +158,11 @@ class FontSelectDialog : DialogFragment(), override fun curFilePath(): String { val pf = parentFragment if (pf is CallBack) { - return pf.curPath + return pf.curFontPath } val activity = activity if (activity is CallBack) { - return activity.curPath + return activity.curFontPath } return "" } @@ -185,6 +185,6 @@ class FontSelectDialog : DialogFragment(), interface CallBack { fun selectFile(path: String) - val curPath: String + val curFontPath: String } } \ No newline at end of file