pull/1463/head^2
gedoor 3 years ago
parent dba07bc9c8
commit e9035ada9b
  1. 4
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 2
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  3. 2
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt

@ -182,9 +182,9 @@ object BookHelp {
*/ */
fun getContent(book: Book, bookChapter: BookChapter): String? { fun getContent(book: Book, bookChapter: BookChapter): String? {
if (book.isLocalTxt() || book.isUmd()) { if (book.isLocalTxt() || book.isUmd()) {
return LocalBook.getContext(book, bookChapter) return LocalBook.getContent(book, bookChapter)
} else if (book.isEpub() && !hasContent(book, bookChapter)) { } else if (book.isEpub() && !hasContent(book, bookChapter)) {
val string = LocalBook.getContext(book, bookChapter) val string = LocalBook.getContent(book, bookChapter)
string?.let { string?.let {
FileUtils.createFileIfNotExist( FileUtils.createFileIfNotExist(
downloadDir, downloadDir,

@ -43,7 +43,6 @@ class EpubFile(var book: Book) {
if (input != null) { if (input != null) {
FileUtils.writeInputStream(file, input) FileUtils.writeInputStream(file, input)
} }
} }
return file return file
} }
@ -136,6 +135,7 @@ class EpubFile(var book: Book) {
private fun getContent(chapter: BookChapter): String? { private fun getContent(chapter: BookChapter): String? {
/*获取当前章节文本*/ /*获取当前章节文本*/
epubBook?.let { epubBook?.let {
it.contents
val body = val body =
Jsoup.parse(String(it.resources.getByHref(chapter.url).data, mCharset)).body() Jsoup.parse(String(it.resources.getByHref(chapter.url).data, mCharset)).body()

@ -43,7 +43,7 @@ object LocalBook {
return chapters return chapters
} }
fun getContext(book: Book, chapter: BookChapter): String? { fun getContent(book: Book, chapter: BookChapter): String? {
return when { return when {
book.isEpub() -> { book.isEpub() -> {
EpubFile.getContent(book, chapter) EpubFile.getContent(book, chapter)

Loading…
Cancel
Save