Android Open Source - ViewPager Fixed Speed Scroller






From Project

Back to project page ViewPager.

License

The source code is released under:

Apache License

If you think the Android project ViewPager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jiahaoliuliu.viewpager;
/*from  w  w w .j a  v a2 s.  co m*/
import android.content.Context;
import android.view.animation.Interpolator;
import android.widget.Scroller;

public class FixedSpeedScroller extends Scroller {

    private int mDuration = 5000;

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

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

    public FixedSpeedScroller(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, mDuration);
    }

    @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);
    }

  public void setFixedDuration(int time) {
    mDuration = time;
  }
}




Java Source Code List

com.jiahaoliuliu.viewpager.FixedSpeedScroller.java
com.jiahaoliuliu.viewpager.ScreenSlidePageFragment.java
com.jiahaoliuliu.viewpager.ViewPagerActivity.java