Skip to content

Commit

Permalink
优化加载会话历史消息逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Oct 22, 2024
1 parent 9908310 commit 62ec7b9
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
}
} else {
moveToBottom = false;
int firstVisibleItem = layoutManager.findFirstCompletelyVisibleItemPosition();
if (firstVisibleItem < 6) {
loadMoreOldMessages();
}
}
}
});
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 62ec7b9

Please sign in to comment.