mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2bdf640284
@ -16,11 +16,12 @@ import io.legado.app.utils.stackTraceStr
|
|||||||
import kotlinx.coroutines.Dispatchers.IO
|
import kotlinx.coroutines.Dispatchers.IO
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.mapLatest
|
import kotlinx.coroutines.flow.mapLatest
|
||||||
|
import java.util.Collections
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
class ExploreShowViewModel(application: Application) : BaseViewModel(application) {
|
class ExploreShowViewModel(application: Application) : BaseViewModel(application) {
|
||||||
val bookshelf = hashSetOf<String>()
|
val bookshelf: MutableSet<String> = Collections.synchronizedSet(hashSetOf<String>())
|
||||||
val upAdapterLiveData = MutableLiveData<String>()
|
val upAdapterLiveData = MutableLiveData<String>()
|
||||||
val booksData = MutableLiveData<List<SearchBook>>()
|
val booksData = MutableLiveData<List<SearchBook>>()
|
||||||
val errorLiveData = MutableLiveData<String>()
|
val errorLiveData = MutableLiveData<String>()
|
||||||
@ -74,7 +75,7 @@ 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>()
|
||||||
for (page in start .. end) {
|
for (page in start..end) {
|
||||||
val books = WebBook.exploreBookAwait(source, url, page)
|
val books = WebBook.exploreBookAwait(source, url, page)
|
||||||
if (books.isEmpty()) break
|
if (books.isEmpty()) break
|
||||||
searchBooks.addAll(books)
|
searchBooks.addAll(books)
|
||||||
|
@ -16,11 +16,12 @@ import io.legado.app.utils.ConflateLiveData
|
|||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.mapLatest
|
import kotlinx.coroutines.flow.mapLatest
|
||||||
|
import java.util.Collections
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
class SearchViewModel(application: Application) : BaseViewModel(application) {
|
class SearchViewModel(application: Application) : BaseViewModel(application) {
|
||||||
val handler = Handler(Looper.getMainLooper())
|
val handler = Handler(Looper.getMainLooper())
|
||||||
val bookshelf = hashSetOf<String>()
|
val bookshelf: MutableSet<String> = Collections.synchronizedSet(hashSetOf<String>())
|
||||||
val upAdapterLiveData = MutableLiveData<String>()
|
val upAdapterLiveData = MutableLiveData<String>()
|
||||||
var searchBookLiveData = ConflateLiveData<List<SearchBook>>(1000)
|
var searchBookLiveData = ConflateLiveData<List<SearchBook>>(1000)
|
||||||
val searchScope: SearchScope = SearchScope(AppConfig.searchScope)
|
val searchScope: SearchScope = SearchScope(AppConfig.searchScope)
|
||||||
|
Loading…
Reference in New Issue
Block a user