Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78933eb6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix bug where scroll position jumps when in overscroll." into ub-launcher3-edmonton

parents be967908 5918662f
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.EdgeEffectFactory;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View;
import android.widget.EdgeEffect;
@@ -58,6 +57,7 @@ public class SpringRelativeLayout extends RelativeLayout {
    private final SpringAnimation mSpring;

    private float mDampedScrollShift = 0;
    private SpringEdgeEffect mActiveEdge;

    public SpringRelativeLayout(Context context) {
        this(context, null);
@@ -90,6 +90,13 @@ public class SpringRelativeLayout extends RelativeLayout {
        return super.drawChild(canvas, child, drawingTime);
    }

    private void setActiveEdge(SpringEdgeEffect edge) {
        if (mActiveEdge != edge && mActiveEdge != null) {
            mActiveEdge.mDistance = 0;
        }
        mActiveEdge = edge;
    }

    private void setDampedScrollShift(float shift) {
        if (shift != mDampedScrollShift) {
            mDampedScrollShift = shift;
@@ -144,6 +151,7 @@ public class SpringRelativeLayout extends RelativeLayout {

        @Override
        public void onPull(float deltaDistance, float displacement) {
            setActiveEdge(this);
            mDistance += deltaDistance * (mVelocityMultiplier / 3f);
            setDampedScrollShift(mDistance * getHeight());
        }