Skip to content

Commit

Permalink
优化双击滑动到下一个未读会话
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Dec 20, 2024
1 parent ada5a96 commit 736cc04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void updateStatusNotification(List<StatusNotification> statusNotification
submit(statusNotifications, this.conversationInfos);
}

private int headerCount() {
public int headerCount() {
return isEmpty(this.statusNotifications) ? 0 : 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ public void onChanged(Object o) {

public void scrollToNextUnreadConversation() {
int start = layoutManager.findFirstVisibleItemPosition();
int end = layoutManager.findLastVisibleItemPosition();
int nextUnreadConversationPosition = adapter.getNextUnreadConversationPosition(start);
if (nextUnreadConversationPosition > 0) {
if (nextUnreadConversationPosition >= start && nextUnreadConversationPosition <= end) {
smoothScroller.setTargetPosition(nextUnreadConversationPosition);
layoutManager.startSmoothScroll(smoothScroller);
} else {
recyclerView.smoothScrollToPosition(nextUnreadConversationPosition);
}
// 支持循环滚动,后面没有未读会话时,从头开始找
if (nextUnreadConversationPosition == -1 && start > adapter.headerCount()) {
nextUnreadConversationPosition = adapter.getNextUnreadConversationPosition(0);
}

if (nextUnreadConversationPosition != -1) {
smoothScroller.setTargetPosition(nextUnreadConversationPosition);
layoutManager.startSmoothScroll(smoothScroller);
}
}

Expand Down

0 comments on commit 736cc04

Please sign in to comment.