From 62ec7b922be439f9b25afd7486d42a1806ebee76 Mon Sep 17 00:00:00 2001 From: imndx Date: Tue, 22 Oct 2024 15:54:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A0=E8=BD=BD=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=8E=86=E5=8F=B2=E6=B6=88=E6=81=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wildfire/chat/kit/conversation/ConversationFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java b/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java index 26a85168..a4aeb647 100644 --- a/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java +++ b/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java @@ -577,6 +577,10 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) { } } else { moveToBottom = false; + int firstVisibleItem = layoutManager.findFirstCompletelyVisibleItemPosition(); + if (firstVisibleItem < 6) { + loadMoreOldMessages(); + } } } }); @@ -1090,7 +1094,6 @@ private void loadMoreOldMessages() { } private void loadMoreOldMessages(boolean scrollToBottom) { - conversationViewModel.loadOldMessages(conversation, targetUser, adapter.getOldestMessageId(), adapter.getOldestMessageUid(), MESSAGE_LOAD_COUNT_PER_TIME, true) .observe(this, uiMessages -> { adapter.addMessagesAtHead(uiMessages);