feat: 优化代码

pull/123/head
kunfei 5 years ago
parent 66b88fab28
commit 3bf94f8cc0
  1. 9
      app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt

@ -68,6 +68,9 @@ class TextPageFactory(dataSource: DataSource) : PageFactory<TextPage>(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<TextPage>(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<TextPage>(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()

Loading…
Cancel
Save