[TEST] Initial force scroll only once

Change-Id: I6f5580be02fbdb13b56c5a180c124076bddcd52a
This commit is contained in:
SpiritCroc 2021-10-27 17:49:24 +02:00
parent 1fdb6923f5
commit 22cdb6544d

View File

@ -70,6 +70,7 @@ class ScrollOnNewMessageCallback(private val layoutManager: BetterLinearLayoutMa
} }
if (scrollToEvent == null) { if (scrollToEvent == null) {
layoutManager.scrollToPositionWithOffset(0, 0) layoutManager.scrollToPositionWithOffset(0, 0)
initialForceScroll = false
layoutManager.setPreferredAnchorPosition(0) layoutManager.setPreferredAnchorPosition(0)
} else { } else {
timelineEventController.searchPositionOfEvent(scrollToEvent)?.let { timelineEventController.searchPositionOfEvent(scrollToEvent)?.let {
@ -78,6 +79,7 @@ class ScrollOnNewMessageCallback(private val layoutManager: BetterLinearLayoutMa
// from the bottom of the view, not the top). // from the bottom of the view, not the top).
val scrollToPosition = max(it + scrollOffset + 1, 0) val scrollToPosition = max(it + scrollOffset + 1, 0)
layoutManager.scrollToPositionWithOffset(scrollToPosition, (parentView.measuredHeight * RoomDetailFragment.TARGET_SCROLL_OUT_FACTOR).toInt()) layoutManager.scrollToPositionWithOffset(scrollToPosition, (parentView.measuredHeight * RoomDetailFragment.TARGET_SCROLL_OUT_FACTOR).toInt())
initialForceScroll = false
layoutManager.setPreferredAnchorPosition(scrollToPosition) layoutManager.setPreferredAnchorPosition(scrollToPosition)
} }
} }