Skip to content

Commit

Permalink
properly set position when toggle is off
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSluffy committed Feb 18, 2024
1 parent 947a2a7 commit 84f47cd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/com/android/launcher3/FastScrollRecyclerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.views.RecyclerViewFastScroller;
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;

import app.lawnchair.preferences2.PreferenceManager2;


/**
Expand All @@ -42,6 +45,8 @@ public abstract class FastScrollRecyclerView extends RecyclerView {

private int savedScrollPosition = RecyclerView.NO_POSITION;

private final PreferenceManager2 pref2;

public FastScrollRecyclerView(Context context) {
this(context, null);
}
Expand All @@ -52,6 +57,7 @@ public FastScrollRecyclerView(Context context, AttributeSet attrs) {

public FastScrollRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
pref2 = PreferenceManager2.getInstance(context);
}

public void bindFastScrollbar(RecyclerViewFastScroller scrollbar) {
Expand Down Expand Up @@ -88,7 +94,8 @@ public int getSavedScrollPosition() {
* Saved the scroll position
*/
public void saveScrollPosition() {
savedScrollPosition = computeVerticalScrollOffset();
savedScrollPosition = PreferenceExtensionsKt.firstBlocking(pref2.getRememberPosition())
? computeVerticalScrollOffset() : 0;
}

/**
Expand Down

0 comments on commit 84f47cd

Please sign in to comment.