feat: 优化代码

pull/105/head
kunfei 5 years ago
parent c0787a8eca
commit 9e402a7cc0
  1. 9
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -123,10 +123,11 @@ class FontSelectDialog : DialogFragment(),
private fun getFontFiles(uri: Uri) { private fun getFontFiles(uri: Uri) {
launch(IO) { launch(IO) {
FileUtils.deleteFile(fontCacheFolder) FileUtils.deleteFile(fontCacheFolder)
DocumentFile.fromTreeUri(App.INSTANCE, uri)?.listFiles()?.forEach { file -> DocumentUtils.listFiles(App.INSTANCE, uri).forEach { item ->
if (file.name?.toLowerCase()?.matches(".*\\.[ot]tf".toRegex()) == true) { if (item.name.toLowerCase().matches(".*\\.[ot]tf".toRegex())) {
DocumentUtils.readBytes(App.INSTANCE, file.uri)?.let { DocumentUtils.readBytes(App.INSTANCE, item.uri)?.let { byteArray ->
FileUtils.createFileIfNotExist(fontCacheFolder + file.name).writeBytes(it) FileUtils.createFileIfNotExist(fontCacheFolder + item.name)
.writeBytes(byteArray)
} }
} }
} }

Loading…
Cancel
Save