Merge remote-tracking branch 'origin/master'

This commit is contained in:
kunfei 2023-07-01 18:26:14 +08:00
commit 2bdf640284
2 changed files with 5 additions and 3 deletions

View File

@ -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)

View File

@ -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)