mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
3c7fb08205
commit
65d5d0cf74
@ -51,6 +51,7 @@ import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import splitties.init.appCtx
|
||||
import kotlin.math.abs
|
||||
|
||||
class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel>(),
|
||||
BookAdapter.CallBack,
|
||||
@ -235,7 +236,20 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (!recyclerView.canScrollVertically(1)) {
|
||||
scrollToBottom()
|
||||
val layoutManager = recyclerView.layoutManager as LinearLayoutManager
|
||||
val lastPosition = layoutManager.findLastCompletelyVisibleItemPosition()
|
||||
if (lastPosition == RecyclerView.NO_POSITION) {
|
||||
return
|
||||
}
|
||||
val lastView = layoutManager.findViewByPosition(lastPosition)
|
||||
if (lastView == null) {
|
||||
scrollToBottom()
|
||||
return
|
||||
}
|
||||
val bottom = abs(lastView.bottom - recyclerView.height)
|
||||
if (bottom <= 1) {
|
||||
scrollToBottom()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -367,6 +381,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
||||
* 开始搜索
|
||||
*/
|
||||
private fun startSearch() {
|
||||
binding.refreshProgressBar.visible()
|
||||
binding.refreshProgressBar.isAutoLoading = true
|
||||
binding.fbStop.visible()
|
||||
}
|
||||
@ -376,6 +391,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
||||
*/
|
||||
private fun searchFinally() {
|
||||
binding.refreshProgressBar.isAutoLoading = false
|
||||
binding.refreshProgressBar.gone()
|
||||
binding.fbStop.invisible()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user