diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt b/app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt index fe18f1b26..8d08a45ca 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt @@ -68,6 +68,9 @@ class TextPageFactory(dataSource: DataSource) : PageFactory(dataSource ?: TextPage(title = it.title).format() } } + if (!hasNextChapter()) { + return@with TextPage(text = "") + } nextChapter?.let { return@with it.page(0)?.removePageAloudSpan() ?: TextPage(title = it.title).format() @@ -83,6 +86,9 @@ class TextPageFactory(dataSource: DataSource) : PageFactory(dataSource ?: TextPage(title = it.title).format() } } + if (!hasPrevChapter()) { + return@with TextPage(text = "") + } prevChapter?.let { return@with it.lastPage()?.removePageAloudSpan() ?: TextPage(title = it.title).format() @@ -97,6 +103,9 @@ class TextPageFactory(dataSource: DataSource) : PageFactory(dataSource return@with it.page(pageIndex + 2)?.removePageAloudSpan() ?: TextPage(title = it.title).format() } + if (!hasNextChapter()) { + TextPage(text = "") + } nextChapter?.let { nc -> if (pageIndex < it.pageSize() - 1) { return@with nc.page(0)?.removePageAloudSpan()