|
|
@@ -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()
|
|
|
}
|
|
|
|