package com.marshalchen.common.ui;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.view.animation.Interpolator;
import android.widget.Scroller;

/**
 * Created by cym on 14-5-8.
 */
public class FixSpeedScroller extends Scroller{
    private int mDuration = 5000;
    private double mScrollFactor = 1;

    public FixSpeedScroller(Context context) {
        super(context);
    }

    public FixSpeedScroller(Context context, Interpolator interpolator) {
        super(context, interpolator);
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public FixSpeedScroller(Context context, Interpolator interpolator, boolean flywheel) {
        super(context, interpolator, flywheel);
    }


    @Override
    public void startScroll(int startX, int startY, int dx, int dy, int duration) {
        // Ignore received duration, use fixed one instead
        super.startScroll(startX, startY, dx, dy, (int) (duration * mScrollFactor));
    }

    @Override
    public void startScroll(int startX, int startY, int dx, int dy) {
        // Ignore received duration, use fixed one instead
        super.startScroll(startX, startY, dx, dy, mDuration);
    }
    /**
     * Set the factor by which the duration will change
     */
    public void setScrollDurationFactor(double scrollFactor) {
        mScrollFactor = scrollFactor;
    }
}

@@ -283,16 +283,17 @@
 Scroller
+ 
 %7B%0A    pr
@@ -314,17 +314,17 @@
 ation = 
-5
+1
 000;%0A   
@@ -964,17 +964,18 @@
  (int) (
-d
+mD
 uration 
@@ -1211,16 +1211,17 @@
 ;%0A    %7D%0A
+%0A
     /**%0A

change FixSpeedScroller