mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
91bc160859
commit
66dcdca85f
@ -16,11 +16,12 @@ import io.legado.app.utils.stackTraceStr
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
import java.util.Collections
|
||||
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class ExploreShowViewModel(application: Application) : BaseViewModel(application) {
|
||||
val bookshelf = hashSetOf<String>()
|
||||
val bookshelf: MutableSet<String> = Collections.synchronizedSet(hashSetOf<String>())
|
||||
val upAdapterLiveData = MutableLiveData<String>()
|
||||
val booksData = MutableLiveData<List<SearchBook>>()
|
||||
val errorLiveData = MutableLiveData<String>()
|
||||
@ -74,7 +75,7 @@ class ExploreShowViewModel(application: Application) : BaseViewModel(application
|
||||
val url = exploreUrl
|
||||
if (source == null || url == null) return emptyList()
|
||||
val searchBooks = arrayListOf<SearchBook>()
|
||||
for (page in start .. end) {
|
||||
for (page in start..end) {
|
||||
val books = WebBook.exploreBookAwait(source, url, page)
|
||||
if (books.isEmpty()) break
|
||||
searchBooks.addAll(books)
|
||||
|
@ -16,11 +16,12 @@ import io.legado.app.utils.ConflateLiveData
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
import java.util.Collections
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class SearchViewModel(application: Application) : BaseViewModel(application) {
|
||||
val handler = Handler(Looper.getMainLooper())
|
||||
val bookshelf = hashSetOf<String>()
|
||||
val bookshelf: MutableSet<String> = Collections.synchronizedSet(hashSetOf<String>())
|
||||
val upAdapterLiveData = MutableLiveData<String>()
|
||||
var searchBookLiveData = ConflateLiveData<List<SearchBook>>(1000)
|
||||
val searchScope: SearchScope = SearchScope(AppConfig.searchScope)
|
||||
|
Loading…
Reference in New Issue
Block a user