feat: 优化代码

pull/172/head
kunfei 5 years ago
parent 19e1d395f4
commit 2d5bbf0e98
  1. 17
      app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt

@ -193,15 +193,18 @@ object AnalyzeTxtFile {
} }
private fun getBookFile(context: Context, book: Book): File { private fun getBookFile(context: Context, book: Book): File {
val uri = Uri.parse(book.bookUrl) if (book.bookUrl.isContentPath()) {
val bookFile = FileUtils.getFile(cacheFolder, book.originName, subDirs = *arrayOf()) val uri = Uri.parse(book.bookUrl)
if (!bookFile.exists()) { val bookFile = FileUtils.getFile(cacheFolder, book.originName, subDirs = *arrayOf())
bookFile.createNewFile() if (!bookFile.exists()) {
DocumentUtils.readBytes(context, uri)?.let { bookFile.createNewFile()
bookFile.writeBytes(it) DocumentUtils.readBytes(context, uri)?.let {
bookFile.writeBytes(it)
}
} }
return bookFile
} }
return bookFile return File(book.bookUrl)
} }
private fun getTocRule(book: Book, bookStream: RandomAccessFile, charset: Charset): Pattern? { private fun getTocRule(book: Book, bookStream: RandomAccessFile, charset: Charset): Pattern? {

Loading…
Cancel
Save