From 570d7e35979a7b4d56f36365a717b2b4994ebb61 Mon Sep 17 00:00:00 2001 From: Ivan Kupalov Date: Sun, 24 Jun 2018 10:53:19 +0200 Subject: [PATCH] Do not scroll to top on timeline refresh (#681) * Do not scroll to top on timeline refresh * Use dp for shifting timeline --- .../keylesspalace/tusky/fragment/TimelineFragment.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index b65f3d573..d94a4226f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -78,6 +78,7 @@ import java.util.regex.Pattern; import javax.inject.Inject; +import at.connyduck.sparkbutton.helpers.Utils; import io.reactivex.android.schedulers.AndroidSchedulers; import retrofit2.Call; import retrofit2.Callback; @@ -1065,11 +1066,8 @@ public class TimelineFragment extends SFragment implements @Override public void onInserted(int position, int count) { adapter.notifyItemRangeInserted(position, count); - if (position == 0 - && layoutManager.findFirstVisibleItemPosition() == 0 - && (swipeRefreshLayout.getVisibility() == View.VISIBLE - || progressBar.getVisibility() == View.VISIBLE)) { - recyclerView.post(() -> layoutManager.scrollToPosition(0)); + if (position == 0) { + recyclerView.scrollBy(0, Utils.dpToPx(Objects.requireNonNull(getContext()), -30)); } }