From 137177d61925200ab9b6161709b5cb31bc4002b2 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 27 Oct 2021 11:08:22 +0200 Subject: [PATCH] Fixed loading more items when scrolling up in chat messages history not working sometimes --- .../org/linphone/activities/main/chat/ChatScrollListener.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/linphone/activities/main/chat/ChatScrollListener.kt b/app/src/main/java/org/linphone/activities/main/chat/ChatScrollListener.kt index 21a97ebcf..440f1d239 100644 --- a/app/src/main/java/org/linphone/activities/main/chat/ChatScrollListener.kt +++ b/app/src/main/java/org/linphone/activities/main/chat/ChatScrollListener.kt @@ -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 }