|
|
@ -148,7 +148,7 @@ object BookHelp { |
|
|
|
|
|
|
|
|
|
|
|
fun getChapterFiles(book: Book): List<String> { |
|
|
|
fun getChapterFiles(book: Book): List<String> { |
|
|
|
val fileNameList = arrayListOf<String>() |
|
|
|
val fileNameList = arrayListOf<String>() |
|
|
|
if (book.isLocalBook()) { |
|
|
|
if (book.isLocalTxt()) { |
|
|
|
return fileNameList |
|
|
|
return fileNameList |
|
|
|
} |
|
|
|
} |
|
|
|
FileUtils.createFolderIfNotExist( |
|
|
|
FileUtils.createFolderIfNotExist( |
|
|
@ -162,7 +162,7 @@ object BookHelp { |
|
|
|
|
|
|
|
|
|
|
|
// 检测该章节是否下载 |
|
|
|
// 检测该章节是否下载 |
|
|
|
fun hasContent(book: Book, bookChapter: BookChapter): Boolean { |
|
|
|
fun hasContent(book: Book, bookChapter: BookChapter): Boolean { |
|
|
|
return if (book.isLocalBook()) { |
|
|
|
return if (book.isLocalTxt()) { |
|
|
|
true |
|
|
|
true |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
FileUtils.exists( |
|
|
|
FileUtils.exists( |
|
|
@ -175,8 +175,19 @@ object BookHelp { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun getContent(book: Book, bookChapter: BookChapter): String? { |
|
|
|
fun getContent(book: Book, bookChapter: BookChapter): String? { |
|
|
|
if (book.isLocalBook()) { |
|
|
|
if (book.isLocalTxt()) { |
|
|
|
return LocalBook.getContext(book, bookChapter) |
|
|
|
return LocalBook.getContext(book, bookChapter) |
|
|
|
|
|
|
|
} else if (book.isEpub() && !hasContent(book, bookChapter)) { |
|
|
|
|
|
|
|
val string = LocalBook.getContext(book, bookChapter) |
|
|
|
|
|
|
|
string?.let { |
|
|
|
|
|
|
|
FileUtils.createFileIfNotExist( |
|
|
|
|
|
|
|
downloadDir, |
|
|
|
|
|
|
|
cacheFolderName, |
|
|
|
|
|
|
|
book.getFolderName(), |
|
|
|
|
|
|
|
bookChapter.getFileName(), |
|
|
|
|
|
|
|
).writeText(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return string |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val file = FileUtils.getFile( |
|
|
|
val file = FileUtils.getFile( |
|
|
|
downloadDir, |
|
|
|
downloadDir, |
|
|
@ -211,7 +222,7 @@ object BookHelp { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun delContent(book: Book, bookChapter: BookChapter) { |
|
|
|
fun delContent(book: Book, bookChapter: BookChapter) { |
|
|
|
if (book.isLocalBook()) { |
|
|
|
if (book.isLocalTxt()) { |
|
|
|
return |
|
|
|
return |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
FileUtils.createFileIfNotExist( |
|
|
|
FileUtils.createFileIfNotExist( |
|
|
|