mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
a23f8eddcd
commit
c302be370f
@ -166,7 +166,12 @@ class ExploreShowActivity : VMBaseActivity<ActivityExploreShowBinding, ExploreSh
|
|||||||
waitDialog.setText("添加书架中...")
|
waitDialog.setText("添加书架中...")
|
||||||
}
|
}
|
||||||
books.forEach {
|
books.forEach {
|
||||||
if (isInBookshelf(it.name, it.author)) return@forEach
|
appDb.bookDao.getBook(it.bookUrl)?.let { book ->
|
||||||
|
book.group = book.group or groupId
|
||||||
|
it.order = appDb.bookDao.minOrder - 1
|
||||||
|
book.save()
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
if (it.tocUrl.isEmpty()) {
|
if (it.tocUrl.isEmpty()) {
|
||||||
val source = appDb.bookSourceDao.getBookSource(it.origin)!!
|
val source = appDb.bookSourceDao.getBookSource(it.origin)!!
|
||||||
WebBook.getBookInfoAwait(source, it)
|
WebBook.getBookInfoAwait(source, it)
|
||||||
|
@ -74,19 +74,12 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
|
|||||||
val url = exploreUrl
|
val url = exploreUrl
|
||||||
if (source == null || url == null) return emptyList()
|
if (source == null || url == null) return emptyList()
|
||||||
val searchBooks = arrayListOf<SearchBook>()
|
val searchBooks = arrayListOf<SearchBook>()
|
||||||
var reverse = false
|
for (page in start .. end) {
|
||||||
val range = if (start <= end) {
|
|
||||||
start .. end
|
|
||||||
} else {
|
|
||||||
reverse = true
|
|
||||||
start downTo end
|
|
||||||
}
|
|
||||||
for (page in range) {
|
|
||||||
val books = WebBook.exploreBookAwait(source, url, page)
|
val books = WebBook.exploreBookAwait(source, url, page)
|
||||||
if (books.isEmpty()) break
|
if (books.isEmpty()) break
|
||||||
if (reverse) books.reverse()
|
|
||||||
searchBooks.addAll(books)
|
searchBooks.addAll(books)
|
||||||
}
|
}
|
||||||
|
searchBooks.reverse()
|
||||||
return searchBooks
|
return searchBooks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user