更新界面

增加搜索进度
增加初次使用引导界面
This commit is contained in:
HapeLee committed 2025-08-27 03:44:43 +08:00
1 parent 50abb9b552
commit 3327f181bd
5 files changed
+57 -11

No files matched your search

@@ -74,6 +74,8 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB
private fun startSearch() {
val precision = appCtx.getPrefBoolean(PreferKey.precisionSearch)
var hasMore = false
val totalParts = bookSourceParts.size
var processedParts = 0
searchJob = scope.launch(searchPool!!) {
flow {
for (bs in bookSourceParts) {
@@ -100,7 +102,8 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB
appDb.searchBookDao.insert(*items.toTypedArray())
mergeItems(items, precision)
currentCoroutineContext().ensureActive()
callBack.onSearchSuccess(searchBooks)
processedParts++
callBack.onSearchSuccess(searchBooks, processedParts, totalParts)
}.onCompletion {
if (it == null) callBack.onSearchFinish(searchBooks.isEmpty(), hasMore)
}.catch {
@@ -191,7 +194,7 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB
interface CallBack {
fun getSearchScope(): SearchScope
fun onSearchStart()
fun onSearchSuccess(searchBooks: List<SearchBook>)
fun onSearchSuccess(searchBooks: List<SearchBook>, processedSources: Int, totalSources: Int)
fun onSearchFinish(isEmpty: Boolean, hasMore: Boolean)
fun onSearchCancel(exception: Throwable? = null)
}