Merge remote-tracking branch 'origin/master'

pull/2037/head
kunfei 2 years ago
commit e116f9eb66
  1. 1
      app/src/main/assets/updateLog.md
  2. 1
      app/src/main/assets/web/bookshelf/css/chunk-vendors.57f380c8.css
  3. 1
      app/src/main/assets/web/bookshelf/css/chunk-vendors.bd1373b6.css
  4. 1
      app/src/main/assets/web/bookshelf/css/detail.155c6df5.css
  5. 1
      app/src/main/assets/web/bookshelf/css/detail.c0f21c6a.css
  6. 4
      app/src/main/assets/web/bookshelf/index.html
  7. 1
      app/src/main/assets/web/bookshelf/js/about.08e76f2a.js
  8. 1
      app/src/main/assets/web/bookshelf/js/about.f487d340.js
  9. 1
      app/src/main/assets/web/bookshelf/js/app.ca73b4d5.js
  10. 1
      app/src/main/assets/web/bookshelf/js/app.ee9eb4c0.js
  11. 53
      app/src/main/assets/web/bookshelf/js/chunk-vendors.3b68c70a.js
  12. 47
      app/src/main/assets/web/bookshelf/js/chunk-vendors.df82d22c.js
  13. 1
      app/src/main/assets/web/bookshelf/js/detail.42f382aa.js
  14. 1
      app/src/main/assets/web/bookshelf/js/detail.dd732add.js
  15. 23
      app/src/main/java/io/legado/app/model/webBook/SearchModel.kt
  16. 16
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  17. 44
      app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt
  18. 1
      app/src/main/java/io/legado/app/ui/widget/recycler/HeaderAdapterDataObserver.kt

@ -17,6 +17,7 @@
* 修复一些bug * 修复一些bug
* webDav书籍排序 * webDav书籍排序
* 更新一些库 * 更新一些库
* web端支持自定义字体 by qianfanguojin
**2022/06/23** **2022/06/23**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="zh-CN" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel="icon" href="../favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"><title>Legado Bookshelf</title><link href="css/about.4f195837.css" rel="prefetch"><link href="css/detail.c0f21c6a.css" rel="prefetch"><link href="js/about.f487d340.js" rel="prefetch"><link href="js/detail.42f382aa.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.bd1373b6.css" rel="preload" as="style"><link href="js/app.ee9eb4c0.js" rel="preload" as="script"><link href="js/chunk-vendors.df82d22c.js" rel="preload" as="script"><link href="css/chunk-vendors.bd1373b6.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"></head><style>body::-webkit-scrollbar { <!DOCTYPE html><html lang="zh-CN" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel="icon" href="../favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"><title>Legado Bookshelf</title><link href="css/about.4f195837.css" rel="prefetch"><link href="css/detail.155c6df5.css" rel="prefetch"><link href="js/about.08e76f2a.js" rel="prefetch"><link href="js/detail.dd732add.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.57f380c8.css" rel="preload" as="style"><link href="js/app.ca73b4d5.js" rel="preload" as="script"><link href="js/chunk-vendors.3b68c70a.js" rel="preload" as="script"><link href="css/chunk-vendors.57f380c8.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"></head><style>body::-webkit-scrollbar {
display: none; display: none;
}</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.df82d22c.js"></script><script src="js/app.ee9eb4c0.js"></script></body></html> }</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.3b68c70a.js"></script><script src="js/app.ca73b4d5.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -16,7 +16,7 @@ import splitties.init.appCtx
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.math.min import kotlin.math.min
class SearchModel(private val scope: CoroutineScope) { class SearchModel(private val scope: CoroutineScope, private val callBack: CallBack) {
val threadCount = AppConfig.threadCount val threadCount = AppConfig.threadCount
private var searchPool: ExecutorCoroutineDispatcher? = null private var searchPool: ExecutorCoroutineDispatcher? = null
private var mSearchId = 0L private var mSearchId = 0L
@ -25,19 +25,10 @@ class SearchModel(private val scope: CoroutineScope) {
private var tasks = CompositeCoroutine() private var tasks = CompositeCoroutine()
private var bookSourceList = arrayListOf<BookSource>() private var bookSourceList = arrayListOf<BookSource>()
private var searchBooks = arrayListOf<SearchBook>() private var searchBooks = arrayListOf<SearchBook>()
private var callBack: CallBack? = null
@Volatile @Volatile
private var searchIndex = -1 private var searchIndex = -1
fun registerCallback(callBack: CallBack) {
this.callBack = callBack
}
fun unRegisterCallback() {
this.callBack = null
}
private fun initSearchPool() { private fun initSearchPool() {
searchPool?.close() searchPool?.close()
searchPool = Executors searchPool = Executors
@ -45,10 +36,10 @@ class SearchModel(private val scope: CoroutineScope) {
} }
fun search(searchId: Long, key: String) { fun search(searchId: Long, key: String) {
callBack?.onSearchStart() callBack.onSearchStart()
if (searchId != mSearchId) { if (searchId != mSearchId) {
if (key.isEmpty()) { if (key.isEmpty()) {
callBack?.onSearchCancel() callBack.onSearchCancel()
return return
} else { } else {
this.searchKey = key this.searchKey = key
@ -62,7 +53,7 @@ class SearchModel(private val scope: CoroutineScope) {
val searchGroup = AppConfig.searchGroup val searchGroup = AppConfig.searchGroup
bookSourceList.clear() bookSourceList.clear()
searchBooks.clear() searchBooks.clear()
callBack?.onSearchSuccess(searchBooks) callBack.onSearchSuccess(searchBooks)
if (searchGroup.isBlank()) { if (searchGroup.isBlank()) {
bookSourceList.addAll(appDb.bookSourceDao.allEnabled) bookSourceList.addAll(appDb.bookSourceDao.allEnabled)
} else { } else {
@ -114,7 +105,7 @@ class SearchModel(private val scope: CoroutineScope) {
appDb.searchBookDao.insert(*items.toTypedArray()) appDb.searchBookDao.insert(*items.toTypedArray())
val precision = appCtx.getPrefBoolean(PreferKey.precisionSearch) val precision = appCtx.getPrefBoolean(PreferKey.precisionSearch)
mergeItems(scope, items, precision) mergeItems(scope, items, precision)
callBack?.onSearchSuccess(searchBooks) callBack.onSearchSuccess(searchBooks)
} }
} }
@ -128,7 +119,7 @@ class SearchModel(private val scope: CoroutineScope) {
if (searchIndex >= bookSourceList.lastIndex if (searchIndex >= bookSourceList.lastIndex
+ min(bookSourceList.size, threadCount) + min(bookSourceList.size, threadCount)
) { ) {
callBack?.onSearchFinish(searchBooks.isEmpty()) callBack.onSearchFinish(searchBooks.isEmpty())
} }
} }
@ -201,7 +192,7 @@ class SearchModel(private val scope: CoroutineScope) {
fun cancelSearch() { fun cancelSearch() {
close() close()
callBack?.onSearchCancel() callBack.onSearchCancel()
} }
fun close() { fun close() {

@ -86,12 +86,12 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.llHistory.setBackgroundColor(backgroundColor) binding.llHistory.setBackgroundColor(backgroundColor)
viewModel.searchFinishCallback = searchFinishCallback
initRecyclerView() initRecyclerView()
initSearchView() initSearchView()
initOtherView() initOtherView()
initData() initData()
receiptIntent(intent) receiptIntent(intent)
viewModel.searchFinishCallback = searchFinishCallback
} }
override fun onNewIntent(data: Intent?) { override fun onNewIntent(data: Intent?) {
@ -219,6 +219,13 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
} }
private fun initData() { private fun initData() {
viewModel.isSearchLiveData.observe(this) {
if (it) {
startSearch()
} else {
searchFinally()
}
}
lifecycleScope.launchWhenStarted { lifecycleScope.launchWhenStarted {
viewModel.searchDataFlow.conflate().collect { viewModel.searchDataFlow.conflate().collect {
adapter.setItems(it) adapter.setItems(it)
@ -234,13 +241,6 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
upGroupMenu() upGroupMenu()
} }
} }
viewModel.isSearchLiveData.observe(this) {
if (it) {
startSearch()
} else {
searchFinally()
}
}
} }
private fun receiptIntent(intent: Intent? = null) { private fun receiptIntent(intent: Intent? = null) {

@ -14,37 +14,37 @@ import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.flowOn
class SearchViewModel(application: Application) : BaseViewModel(application) { class SearchViewModel(application: Application) : BaseViewModel(application) {
private val searchModel = SearchModel(viewModelScope) private val searchModel = SearchModel(viewModelScope, object : SearchModel.CallBack {
override fun onSearchStart() {
isSearchLiveData.postValue(true)
}
override fun onSearchSuccess(searchBooks: ArrayList<SearchBook>) {
searchFlowCallBack?.invoke(searchBooks)
}
override fun onSearchFinish(isEmpty: Boolean) {
isSearchLiveData.postValue(false)
searchFinishCallback?.invoke(isEmpty)
}
override fun onSearchCancel() {
isSearchLiveData.postValue(false)
}
})
var searchFinishCallback: ((isEmpty: Boolean) -> Unit)? = null var searchFinishCallback: ((isEmpty: Boolean) -> Unit)? = null
var isSearchLiveData = MutableLiveData<Boolean>() var isSearchLiveData = MutableLiveData<Boolean>()
var searchKey: String = "" var searchKey: String = ""
private var searchID = 0L private var searchID = 0L
private var searchFlowCallBack: ((searchBooks: ArrayList<SearchBook>) -> Unit)? = null
val searchDataFlow = callbackFlow { val searchDataFlow = callbackFlow {
val callback = object : SearchModel.CallBack { searchFlowCallBack = {
override fun onSearchStart() { trySend(ArrayList(it))
isSearchLiveData.postValue(true)
}
override fun onSearchSuccess(searchBooks: ArrayList<SearchBook>) {
trySend(ArrayList(searchBooks))
}
override fun onSearchFinish(isEmpty: Boolean) {
isSearchLiveData.postValue(false)
searchFinishCallback?.invoke(isEmpty)
}
override fun onSearchCancel() {
isSearchLiveData.postValue(false)
}
} }
searchModel.registerCallback(callback)
awaitClose { awaitClose {
searchModel.unRegisterCallback() searchFlowCallBack = null
} }
}.flowOn(IO) }.flowOn(IO)

@ -2,6 +2,7 @@ package io.legado.app.ui.widget.recycler
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@Suppress("unused")
internal class HeaderAdapterDataObserver( internal class HeaderAdapterDataObserver(
private var adapterDataObserver: RecyclerView.AdapterDataObserver, private var adapterDataObserver: RecyclerView.AdapterDataObserver,
private var headerCount: Int private var headerCount: Int

Loading…
Cancel
Save