diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index 8d158b960..b171680d1 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -261,8 +261,6 @@ class EpubFile(var book: Book) { } } } - book.latestChapterTitle = chapterList.lastOrNull()?.title - book.totalChapterNum = chapterList.size return chapterList } diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index eae54864f..11bb5f85a 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -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? { diff --git a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt index 2d726d843..b283dd895 100644 --- a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt @@ -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 } diff --git a/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt b/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt index 9e1a38b48..963d2eb69 100644 --- a/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/UmdFile.kt @@ -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 }