Skip to content

Commit

Permalink
e
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-primary committed Sep 11, 2016
1 parent bc2b5e2 commit bdc20ac
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.Scroller;
Expand Down Expand Up @@ -60,7 +61,8 @@ public class FlingLayout extends FrameLayout implements NestedScrollingChild, Ne
private boolean isScrolling = false;
protected float tepmX;
protected float tepmY;
private static final int MAX_DURATION = 300;
private static final int MAX_DURATION = 600;
private static final int MIN_DURATION = 300;
private boolean canPullUp = true;
private boolean canPullDown = true;
protected OnScrollListener mOnScrollListener;
Expand Down Expand Up @@ -91,7 +93,7 @@ public FlingLayout(Context context, AttributeSet attrs, int defStyle) {
public void init(Context context) {
version = android.os.Build.VERSION.SDK_INT;
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mScroller = new Scroller(context, new DecelerateInterpolator());
mScroller = new Scroller(context, new AccelerateDecelerateInterpolator());
mParentHelper = new NestedScrollingParentHelper(this);
mChildHelper = new NestedScrollingChildHelper(this);
}
Expand Down Expand Up @@ -180,7 +182,8 @@ public float getMoveY() {
public int startMoveBy(float startY, float dy) {
setScrollState(SCROLL_STATE_FLING);
int duration = (int) Math.abs(dy);
int time = duration > MAX_DURATION ? MAX_DURATION : duration;
int time = Math.min(MAX_DURATION,duration);
time = Math.max(MIN_DURATION,time);
mScroller.startScroll(0, (int) startY, 0, (int) dy, time);
invalidate();
return time;
Expand Down

0 comments on commit bdc20ac

Please sign in to comment.