Further move up targeted message

Change-Id: I48a470686ebe7283f9ffd39ebbc2c14d41e37235
This commit is contained in:
SpiritCroc 2021-08-06 16:34:54 +02:00
parent c28c57a4ef
commit 2d1ac76698
2 changed files with 8 additions and 6 deletions

View File

@ -268,6 +268,8 @@ class RoomDetailFragment @Inject constructor(
}
private const val ircPattern = " (IRC)"
const val TARGET_SCROLL_OUT_FACTOR = 7f/8f
}
private val galleryOrCameraDialogHelper = GalleryOrCameraDialogHelper(this, colorProvider)
@ -835,10 +837,10 @@ class RoomDetailFragment @Inject constructor(
scrollOnHighlightedEventCallback.scheduleScrollTo(action.eventId)
} else {
views.timelineRecyclerView.stopScroll()
// Scroll such that the scrolled-to event is moved down 1/3 of the screen.
// To do that, we actually scroll the view above out by 2/3 (since we can only control the distance
// Scroll such that the scrolled-to event is moved down (1-TARGET_SCROLL_OUT_FACTOR) of the screen.
// To do that, we actually scroll the view above out by TARGET_SCROLL_OUT_FACTOR (since we can only control the distance
// from the bottom of the view, not the top).
layoutManager.scrollToPositionWithOffset(scrollPosition + 1, views.timelineRecyclerView.measuredHeight * 2 / 3)
layoutManager.scrollToPositionWithOffset(scrollPosition + 1, (views.timelineRecyclerView.measuredHeight * TARGET_SCROLL_OUT_FACTOR).toInt())
}
}

View File

@ -66,11 +66,11 @@ class ScrollOnNewMessageCallback(private val layoutManager: LinearLayoutManager,
layoutManager.scrollToPositionWithOffset(0, 0)
} else {
timelineEventController.searchPositionOfEvent(scrollToEvent)?.let {
// Scroll such that the scrolled-to event is moved down 1/3 of the screen.
// To do that, we actually scroll the view above out by 2/3 (since we can only control the distance
// Scroll such that the scrolled-to event is moved down (1-TARGET_SCROLL_OUT_FACTOR) of the screen.
// To do that, we actually scroll the view above out by TARGET_SCROLL_OUT_FACTOR (since we can only control the distance
// from the bottom of the view, not the top).
val scrollToPosition = max(it + scrollOffset + 1, 0)
layoutManager.scrollToPositionWithOffset(scrollToPosition, parentView.measuredHeight * 2 / 3)
layoutManager.scrollToPositionWithOffset(scrollToPosition, (parentView.measuredHeight * RoomDetailFragment.TARGET_SCROLL_OUT_FACTOR).toInt())
}
}
return