feat: update book in LocalBook.getChapterList

pull/2237/head
Xwite 2 years ago
parent 5e7b5d1f40
commit c5b9b52650
  1. 2
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  2. 9
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt
  3. 3
      app/src/main/java/io/legado/app/model/localBook/TextFile.kt
  4. 2
      app/src/main/java/io/legado/app/model/localBook/UmdFile.kt

@ -261,8 +261,6 @@ class EpubFile(var book: Book) {
}
}
}
book.latestChapterTitle = chapterList.lastOrNull()?.title
book.totalChapterNum = chapterList.size
return chapterList
}

@ -78,9 +78,12 @@ object LocalBook {
if (chapters.isEmpty()) {
throw TocEmptyException(appCtx.getString(R.string.chapter_list_empty))
}
val lh = LinkedHashSet(chapters)
lh.forEachIndexed { index, bookChapter -> bookChapter.index = index }
return ArrayList(lh)
val list = ArrayList(LinkedHashSet(chapters))
list.forEachIndexed { index, bookChapter -> bookChapter.index = index }
book.latestChapterTitle = list.last().title
book.totalChapterNum = list.size
book.save()
return list
}
fun getContent(book: Book, chapter: BookChapter): String? {

@ -77,9 +77,6 @@ class TextFile(private val book: Book) {
bookChapter.bookUrl = book.bookUrl
bookChapter.url = MD5Utils.md5Encode16(book.originName + index + bookChapter.title)
}
book.latestChapterTitle = toc.last().title
book.totalChapterNum = toc.size
book.save()
return toc
}

@ -112,8 +112,6 @@ class UmdFile(var book: Book) {
DebugLog.d(javaClass.name, chapter.url)
chapterList.add(chapter)
}
book.latestChapterTitle = chapterList.lastOrNull()?.title
book.totalChapterNum = chapterList.size
return chapterList
}

Loading…
Cancel
Save