mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +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.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel>(),
|
class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel>(),
|
||||||
BookAdapter.CallBack,
|
BookAdapter.CallBack,
|
||||||
@ -235,7 +236,20 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
|||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
if (!recyclerView.canScrollVertically(1)) {
|
if (!recyclerView.canScrollVertically(1)) {
|
||||||
|
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()
|
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() {
|
private fun startSearch() {
|
||||||
|
binding.refreshProgressBar.visible()
|
||||||
binding.refreshProgressBar.isAutoLoading = true
|
binding.refreshProgressBar.isAutoLoading = true
|
||||||
binding.fbStop.visible()
|
binding.fbStop.visible()
|
||||||
}
|
}
|
||||||
@ -376,6 +391,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
|||||||
*/
|
*/
|
||||||
private fun searchFinally() {
|
private fun searchFinally() {
|
||||||
binding.refreshProgressBar.isAutoLoading = false
|
binding.refreshProgressBar.isAutoLoading = false
|
||||||
|
binding.refreshProgressBar.gone()
|
||||||
binding.fbStop.invisible()
|
binding.fbStop.invisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user