pull/71/head
kunfei 5 years ago
parent df70ca8f56
commit 22c17683fd
  1. 30
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -88,13 +88,13 @@ 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?.let { (parentFragment as? CallBack)?.let {
if (it is CallBack && it.curFontPath != "") { if (it.curFontPath != "") {
it.selectFile("") it.selectFile("")
} }
} }
activity?.let { (activity as? CallBack)?.let {
if (it is CallBack && it.curFontPath != "") { if (it.curFontPath != "") {
it.selectFile("") it.selectFile("")
} }
} }
@ -168,13 +168,13 @@ class FontSelectDialog : DialogFragment(),
override fun onClick(file: File) { override fun onClick(file: File) {
file.absolutePath.let { path -> file.absolutePath.let { path ->
parentFragment?.let { (parentFragment as? CallBack)?.let {
if (it is CallBack && it.curFontPath != path) { if (it.curFontPath != path) {
it.selectFile(path) it.selectFile(path)
} }
} }
activity?.let { (activity as? CallBack)?.let {
if (it is CallBack && it.curFontPath != path) { if (it.curFontPath != path) {
it.selectFile(path) it.selectFile(path)
} }
} }
@ -183,17 +183,9 @@ class FontSelectDialog : DialogFragment(),
} }
override fun curFilePath(): String { override fun curFilePath(): String {
parentFragment?.let { return (parentFragment as? CallBack)?.curFontPath
if (it is CallBack) { ?: (activity as? CallBack)?.curFontPath
return it.curFontPath ?: ""
}
}
activity?.let {
if (it is CallBack) {
return it.curFontPath
}
}
return ""
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

Loading…
Cancel
Save