Android Open Source - PECSMobile Smooth Scroller View Pager






From Project

Back to project page PECSMobile.

License

The source code is released under:

GNU General Public License

If you think the Android project PECSMobile 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.jjoseba.pecsmobile.ui;
//from  w  ww . java 2  s  . com
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;

import java.lang.reflect.Field;

/**
 * Created by Joseba on 28/12/2014.
 */
public class SmoothScrollerViewPager extends EnableableViewPager {


    public SmoothScrollerViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
        setMyScroller();
    }

    private void setMyScroller()
    {
        try
        {
            Class<?> viewpager = ViewPager.class;
            Field scroller = viewpager.getDeclaredField("mScroller");
            scroller.setAccessible(true);
            scroller.set(this, new SmoothScroller(getContext()));
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public class SmoothScroller extends Scroller
    {
        public SmoothScroller(Context context)
        {
            super(context, new DecelerateInterpolator());
        }

        @Override
        public void startScroll(int startX, int startY, int dx, int dy, int duration)
        {
            super.startScroll(startX, startY, dx, dy, 700);
        }
    }
}




Java Source Code List

com.jjoseba.pecsmobile.ApplicationTest.java
com.jjoseba.pecsmobile.CardsPage.java
com.jjoseba.pecsmobile.activity.CardsActivity.java
com.jjoseba.pecsmobile.adapter.CardGridAdapter.java
com.jjoseba.pecsmobile.model.CardPECS.java
com.jjoseba.pecsmobile.ui.EnableableViewPager.java
com.jjoseba.pecsmobile.ui.GridItemClickedListener.java
com.jjoseba.pecsmobile.ui.SmoothScrollerViewPager.java
com.jjoseba.pecsmobile.ui.ZoomOutPageTransformer.java
com.jjoseba.pecsmobile.util.SystemUiHiderBase.java
com.jjoseba.pecsmobile.util.SystemUiHiderHoneycomb.java
com.jjoseba.pecsmobile.util.SystemUiHider.java