Example usage for android.widget Scroller Scroller

List of usage examples for android.widget Scroller Scroller

Introduction

In this page you can find the example usage for android.widget Scroller Scroller.

Prototype

public Scroller(Context context, Interpolator interpolator) 

Source Link

Document

Create a Scroller with the specified interpolator.

Usage

From source file:com.slidinglayer.SlidingPanel.java

private void init() {
    setWillNotDraw(false);//from   w  w w . j a  v a 2  s . c o m
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sMenuInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    setOffsetWidth((int) (DEFAULT_OFFSET * density + 0.5f));
}

From source file:com.aretha.slidemenu.SlideMenu.java

public SlideMenu(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // we want to draw drop shadow of content
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mVelocityTracker = VelocityTracker.obtain();
    mScroller = new Scroller(context, mInterpolator);
    mContentHitRect = new Rect();
    STATUS_BAR_HEIGHT = (int) getStatusBarHeight(context);
    setWillNotDraw(false);//from w w  w. ja  v a 2s.  c  o m

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlideMenu, defStyle, 0);

    // Set the shadow attributes
    setPrimaryShadowWidth(a.getDimension(R.styleable.SlideMenu_primaryShadowWidth, 30));
    setSecondaryShadowWidth(a.getDimension(R.styleable.SlideMenu_secondaryShadowWidth, 30));

    Drawable primaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable);
    if (null == primaryShadowDrawable) {
        primaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.TRANSPARENT, Color.argb(99, 0, 0, 0) });
    }
    setPrimaryShadowDrawable(primaryShadowDrawable);

    Drawable secondaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable);
    if (null == secondaryShadowDrawable) {
        secondaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.argb(99, 0, 0, 0), Color.TRANSPARENT });
    }
    setSecondaryShadowDrawable(secondaryShadowDrawable);

    mSlideDirectionFlag = a.getInt(R.styleable.SlideMenu_slideDirection,
            FLAG_DIRECTION_LEFT | FLAG_DIRECTION_RIGHT);
    setFocusable(true);
    setFocusableInTouchMode(true);
    a.recycle();
}

From source file:com.coco.slidinguppanel.SlidingUpPanel.java

private void initSlidingUpPanel() {
    setWillNotDraw(false);//from  w ww  .ja  v  a 2s  .c o m
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);

    final Context context = getContext();
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mScroller = new Scroller(context, new BounceInterpolator());
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.dongdong.wheel.WheelView.java

/**
 * Set the the specified scrolling interpolator
 *
 * @param interpolator the interpolator/* w  ww.  jav a 2  s .c  o m*/
 */
public void setInterpolator(Interpolator interpolator) {
    mScroller.forceFinished(true);
    mScroller = new Scroller(getContext(), interpolator);
}

From source file:com.aviary.android.feather.sdk.widget.AviaryWorkspace.java

private void initWorkspace(Context context, AttributeSet attrs, int defStyle) {

    Theme theme = context.getTheme();/*from  www .  j  a  v a2 s.c  o m*/

    TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.AviaryWorkspace, defStyle, 0);
    mDefaultScreen = a.getInt(R.styleable.AviaryWorkspace_aviary_defaultScreen, 0);
    int overscrollMode = a.getInt(R.styleable.AviaryWorkspace_aviary_overscroll, 0);
    a.recycle();

    setHapticFeedbackEnabled(false);

    mScrollInterpolator = new DecelerateInterpolator(1.0f);
    mScroller = new Scroller(context, mScrollInterpolator);
    mPreviousScreen = INVALID_SCREEN;

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    mPaddingTop = getPaddingTop();
    mPaddingBottom = getPaddingBottom();
    mPaddingLeft = getPaddingLeft();
    mPaddingRight = getPaddingRight();

    setOverScroll(overscrollMode);
}

From source file:gaobq.android.easyslidingmenu.CustomViewAbove.java

void initCustomViewAbove() {
    setWillNotDraw(false);/*ww w . j a v a  2  s  . c o m*/
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    setInternalPageChangeListener(new SimpleOnPageChangeListener() {
        public void onPageSelected(int position) {
            if (mViewBehind != null) {
                switch (position) {
                case 0:
                case 2:
                    mViewBehind.setChildrenEnabled(true);
                    break;
                case 1:
                    mViewBehind.setChildrenEnabled(false);
                    break;
                }
            }
        }
    });

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}

From source file:com.abslyon.abetterselection.CoverFlow.CoverFlowView.java

private void init() {
    setWillNotDraw(false);/*  w  ww.jav a  2 s. com*/
    setClickable(true);

    mChildTransfromer = new Matrix();
    mReflectionTransfromer = new Matrix();

    mTouchRect = new RectF();

    mImageRecorder = new SparseArray<int[]>();

    mDrawChildPaint = new Paint();
    mDrawChildPaint.setAntiAlias(true);
    mDrawChildPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    mCoverFlowPadding = new Rect();

    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(getContext(), new AccelerateDecelerateInterpolator());

    mRemoveReflectionPendingArray = new ArrayList<Integer>();
}

From source file:com.dolphinwang.imagecoverflow.CoverFlowView.java

private void init() {
    setWillNotDraw(false);/*from  ww w  .j a  va 2s .  c om*/
    setClickable(true);

    mChildTransfromer = new Matrix();
    mReflectionTransfromer = new Matrix();

    mTouchRect = new RectF();

    mTouchRect2 = new ArrayList<RectF>();
    for (int i = 0; i < 5; i++) {
        RectF a = new RectF();
        mTouchRect2.add(a);
    }

    mImageRecorder = new SparseArray<int[]>();

    mDrawChildPaint = new Paint();
    mDrawChildPaint.setAntiAlias(true);
    mDrawChildPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    mCoverFlowPadding = new Rect();

    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(getContext(), new AccelerateDecelerateInterpolator());

    mRemoveReflectionPendingArray = new ArrayList<Integer>();
}

From source file:tw.medfirst.com.project.baseview.CoverFlowView.java

private void init() {
    setWillNotDraw(false);//from   w w  w .  jav  a  2s  .c  om
    setClickable(true);

    mChildTransfromer = new Matrix();
    mReflectionTransfromer = new Matrix();

    mTouchRect = new RectF();
    mTouchRect2 = new ArrayList<RectF>();
    for (int i = 0; i < VISIBLE_VIEWS * 2 + 1; i++) {
        RectF r = new RectF();
        mTouchRect2.add(r);
    }

    mImageRecorder = new SparseArray<int[]>();

    mDrawChildPaint = new Paint();
    mDrawChildPaint.setAntiAlias(true);
    mDrawChildPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    mCoverFlowPadding = new Rect();

    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mScroller = new Scroller(getContext(), new AccelerateDecelerateInterpolator());

    mRemoveReflectionPendingArray = new ArrayList<Integer>();
}

From source file:com.danilov.supermanga.core.view.SlidingLayer.java

private void init() {
    setWillNotDraw(false);// w w  w.j a v a 2s. c o m
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sMenuInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);

    mRandom = new Random();
}