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) {
launch(IO) {
FileUtils.deleteFile(fontCacheFolder)
DocumentFile.fromTreeUri(App.INSTANCE, uri)?.listFiles()?.forEach { file ->
if (file.name?.toLowerCase()?.matches(".*\\.[ot]tf".toRegex()) == true) {
DocumentUtils.readBytes(App.INSTANCE, file.uri)?.let {
FileUtils.createFileIfNotExist(fontCacheFolder + file.name).writeBytes(it)
DocumentUtils.listFiles(App.INSTANCE, uri).forEach { item ->
if (item.name.toLowerCase().matches(".*\\.[ot]tf".toRegex())) {
DocumentUtils.readBytes(App.INSTANCE, item.uri)?.let { byteArray ->
FileUtils.createFileIfNotExist(fontCacheFolder + item.name)
.writeBytes(byteArray)
}
}
}

Loading…
Cancel
Save