pull/71/head^2^2
kunfei 5 years ago
parent a7d157db34
commit b032acca6a
  1. 18
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -90,12 +90,8 @@ class FontSelectDialog : DialogFragment(),
override fun onMenuItemClick(item: MenuItem?): Boolean { override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) { when (item?.itemId) {
R.id.menu_default -> { R.id.menu_default -> {
(parentFragment as? CallBack)?.let { val cb = (parentFragment as? CallBack) ?: (activity as? CallBack)
if (it.curFontPath != "") { cb?.let {
it.selectFile("")
}
}
(activity as? CallBack)?.let {
if (it.curFontPath != "") { if (it.curFontPath != "") {
it.selectFile("") it.selectFile("")
} }
@ -170,20 +166,20 @@ class FontSelectDialog : DialogFragment(),
} }
override fun onClick(file: File) { override fun onClick(file: File) {
launch(IO) {
file.copyTo(FileHelp.getFile(fontFolder + file.name)).absolutePath.let { path -> file.copyTo(FileHelp.getFile(fontFolder + file.name)).absolutePath.let { path ->
(parentFragment as? CallBack)?.let { val cb = (parentFragment as? CallBack) ?: (activity as? CallBack)
cb?.let {
if (it.curFontPath != path) { if (it.curFontPath != path) {
withContext(Main) {
it.selectFile(path) it.selectFile(path)
} }
} }
(activity as? CallBack)?.let {
if (it.curFontPath != path) {
it.selectFile(path)
}
} }
} }
dialog?.dismiss() dialog?.dismiss()
} }
}
override fun curFilePath(): String { override fun curFilePath(): String {
return (parentFragment as? CallBack)?.curFontPath return (parentFragment as? CallBack)?.curFontPath

Loading…
Cancel
Save