Skip to content

Commit

Permalink
build: 4.0.0-beta14
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang2 committed May 30, 2023
1 parent 39d865d commit 0324bb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
signing
}

val versionName = "4.0.0-beta13"
val versionName = "4.0.0-beta14"


android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ abstract class LeadingLoadStateAdapter<VH: RecyclerView.ViewHolder> : LoadStateA
*/
var preloadSize = 0

private var mDelayNextLoadFlag: Boolean = false

override fun displayLoadStateAsItem(loadState: LoadState): Boolean {
return loadState is LoadState.Loading
}
Expand All @@ -47,13 +49,17 @@ abstract class LeadingLoadStateAdapter<VH: RecyclerView.ViewHolder> : LoadStateA
private fun loadAction() {
if (!isLoadEnable || onLeadingListener?.isAllowLoading() == false) return

if (mDelayNextLoadFlag) return

if (loadState is LoadState.NotLoading && !loadState.endOfPaginationReached) {
val recyclerView = recyclerView ?: return

if (recyclerView.isComputingLayout) {
// 如果 RecyclerView 当前正在计算布局,则延迟执行,避免崩溃
// To avoid crash. Delay to load more if the recyclerview is computingLayout.
mDelayNextLoadFlag = true
recyclerView.post {
mDelayNextLoadFlag = false
invokeLoad()
}
return
Expand Down

0 comments on commit 0324bb5

Please sign in to comment.