优化
This commit is contained in:
@@ -241,14 +241,36 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
showDialogFragment(ChangeSourceDialog(it.name, it.author))
|
||||
}
|
||||
}
|
||||
R.id.menu_refresh -> {
|
||||
R.id.menu_refresh_dur -> {
|
||||
if (ReadBook.bookSource == null) {
|
||||
upContent()
|
||||
} else {
|
||||
ReadBook.book?.let {
|
||||
ReadBook.curTextChapter = null
|
||||
binding.readView.upContent()
|
||||
viewModel.refreshContent(it)
|
||||
viewModel.refreshContentDur(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
R.id.menu_refresh_after -> {
|
||||
if (ReadBook.bookSource == null) {
|
||||
upContent()
|
||||
} else {
|
||||
ReadBook.book?.let {
|
||||
ReadBook.clearTextChapter()
|
||||
binding.readView.upContent()
|
||||
viewModel.refreshContentAfter(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
R.id.menu_refresh_all -> {
|
||||
if (ReadBook.bookSource == null) {
|
||||
upContent()
|
||||
} else {
|
||||
ReadBook.book?.let {
|
||||
ReadBook.clearTextChapter()
|
||||
binding.readView.upContent()
|
||||
viewModel.refreshContentAll(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshContent(book: Book) {
|
||||
fun refreshContentDur(book: Book) {
|
||||
execute {
|
||||
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
|
||||
?.let { chapter ->
|
||||
@@ -263,6 +263,26 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshContentAfter(book: Book) {
|
||||
execute {
|
||||
appDb.bookChapterDao.getChapterList(
|
||||
book.bookUrl,
|
||||
ReadBook.durChapterIndex,
|
||||
book.totalChapterNum
|
||||
).forEach { chapter ->
|
||||
BookHelp.delContent(book, chapter)
|
||||
}
|
||||
ReadBook.loadContent(false)
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshContentAll(book: Book) {
|
||||
execute {
|
||||
BookHelp.clearCache(book)
|
||||
ReadBook.loadContent(false)
|
||||
}
|
||||
}
|
||||
|
||||
fun reverseContent(book: Book) {
|
||||
execute {
|
||||
appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex)
|
||||
|
||||
Reference in New Issue
Block a user