From 1480c6aa3ac5c0c2d362fb271f47ea2259ab14e2 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 12 Dec 2022 13:31:18 +0100 Subject: [PATCH] Jump to top if swipe/refresh while preferring newest-first order --- .../tusky/components/timeline/TimelineFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt index 63e84df03..d05278b29 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/timeline/TimelineFragment.kt @@ -237,7 +237,9 @@ class TimelineFragment : if (positionStart == 0 && adapter.itemCount != itemCount) { binding.recyclerView.post { if (getView() != null) { - if (isSwipeToRefreshEnabled) { + // Swiping and prefer oldest-first? Stay at the same position. + // Otherwise jump to the top. + if (isSwipeToRefreshEnabled && readingOrder == ReadingOrder.OLDEST_FIRST) { binding.recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)) } else binding.recyclerView.scrollToPosition(0) }