Fixed loading more items when scrolling up in chat messages history not working sometimes

This commit is contained in:
Sylvain Berfini 2021-10-27 11:08:22 +02:00
parent db45a2bb78
commit 137177d619

View file

@ -67,7 +67,11 @@ internal abstract class ChatScrollListener(private val mLayoutManager: LinearLay
// the mVisibleThreshold and need to reload more data.
// If we do need to reload some more data, we execute onLoadMore to fetch the data.
// threshold should reflect how many total columns there are too
if (!loading && firstVisibleItemPosition < mVisibleThreshold && firstVisibleItemPosition > 0 && lastVisibleItemPosition < totalItemCount - mVisibleThreshold) {
if (!loading &&
firstVisibleItemPosition < mVisibleThreshold &&
firstVisibleItemPosition >= 0 &&
lastVisibleItemPosition < totalItemCount - mVisibleThreshold
) {
onLoadMore(totalItemCount)
loading = true
}