Merge pull request #118 from hingbong/master

选择字体文件夹弹出框用协程处理
pull/120/head
kunfei 5 years ago committed by GitHub
commit cdb2f9f86a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/io/legado/app/help/storage/Backup.kt
  2. 4
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -102,7 +102,7 @@ object Backup {
if (file.exists()) { if (file.exists()) {
treeDoc.findFile(fileName)?.delete() treeDoc.findFile(fileName)?.delete()
treeDoc.createFile("", fileName)?.let { treeDoc.createFile("", fileName)?.let {
DocumentUtils.writeText(context, file.readText(), it.uri) DocumentUtils.writeBytes(context, file.readBytes(), it.uri)
} }
} }
} }

@ -109,6 +109,7 @@ class FontSelectDialog : BaseDialogFragment(),
} }
private fun openFolder() { private fun openFolder() {
launch(Main) {
alert { alert {
titleResource = R.string.select_folder titleResource = R.string.select_folder
items(resources.getStringArray(R.array.select_folder).toList()) { _, index -> items(resources.getStringArray(R.array.select_folder).toList()) { _, index ->
@ -145,6 +146,7 @@ class FontSelectDialog : BaseDialogFragment(),
} }
}.show() }.show()
} }
}
@SuppressLint("DefaultLocale") @SuppressLint("DefaultLocale")
private fun getFontFiles(doc: DocumentFile) { private fun getFontFiles(doc: DocumentFile) {
@ -261,7 +263,7 @@ class FontSelectDialog : BaseDialogFragment(),
} }
} }
private fun onDefaultFontChange(callBack: CallBack){ private fun onDefaultFontChange(callBack: CallBack) {
if (curFilePath() == "") { if (curFilePath() == "") {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} else { } else {

Loading…
Cancel
Save