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.klinker.android.sliding.MultiShrinkScroller.java

/**
 * Create a new instance of MultiShrinkScroller.
 * @param context//from w w w.  j a  v  a2 s . c  o m
 * @param attrs
 * @param defStyleAttr
 */
public MultiShrinkScroller(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    setFocusable(false);
    setWillNotDraw(false);

    edgeGlowBottom = new EdgeEffect(context);
    edgeGlowTop = new EdgeEffect(context);
    scroller = new Scroller(context, INTERPOLATOR);
    touchSlop = configuration.getScaledTouchSlop();
    minimumVelocity = configuration.getScaledMinimumFlingVelocity();
    maximumVelocity = configuration.getScaledMaximumFlingVelocity();
    transparentStartHeight = (int) getResources().getDimension(R.dimen.sliding_starting_empty_height);
    toolbarElevation = getResources().getDimension(R.dimen.sliding_toolbar_elevation);
    isTwoPanel = getResources().getBoolean(R.bool.sliding_two_panel);
    maximumTitleMargin = (int) getResources().getDimension(R.dimen.sliding_title_initial_margin);

    dismissDistanceOnScroll = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_scroll);
    dismissDistanceOnRelease = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_release);
    snapToTopSlopHeight = (int) getResources().getDimension(R.dimen.sliding_snap_to_top_slop_height);

    final TypedValue photoRatio = new TypedValue();
    getResources().getValue(R.dimen.sliding_landscape_photo_ratio, photoRatio, true);
    landscapePhotoRatio = photoRatio.getFloat();

    final TypedArray attributeArray = context
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    actionBarSize = attributeArray.getDimensionPixelSize(0, 0);
    minimumHeaderHeight = actionBarSize;
    attributeArray.recycle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        textSizePathInterpolator = new PathInterpolator(X1, Y1, X2, Y2);
    } else {
        textSizePathInterpolator = null;
    }
}

From source file:com.example.refresh.draggridview.DraggableGridViewPager.java

private void initDraggableGridViewPager() {
    setWillNotDraw(false);//from w  w w. ja  va2s . c om
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    setChildrenDrawingOrderEnabled(true);

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

    mGridGap = (int) (DEFAULT_GRID_GAP * density);

    // internal paddings
    mPaddingLeft = getPaddingLeft();
    mPaddingTop = getPaddingTop();
    mPaddingRight = getPaddingRight();
    mPaddingButtom = getPaddingBottom();
    super.setPadding(0, 0, 0, 0);

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

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);

}

From source file:com.coco.draggablegridviewpager.DraggableGridViewPager.java

private void initDraggableGridViewPager() {
    setWillNotDraw(false);//from w w  w  .  j a v  a 2s  .  com
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    setChildrenDrawingOrderEnabled(true);

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

    mGridGap = (int) (DEFAULT_GRID_GAP * density);

    // internal paddings
    mPaddingLeft = getPaddingLeft();
    mPaddingTop = getPaddingTop();
    mPaddingRight = getPaddingRight();
    mPaddingButtom = getPaddingBottom();
    super.setPadding(0, 0, 0, 0);

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

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
}

From source file:com.android.launcher2.PagedView.java

/**
 * Initializes various states for this workspace.
 */// www .  ja v a  2  s  . c  o m
protected void init() {
    mDirtyPageContent = new ArrayList<Boolean>();
    mDirtyPageContent.ensureCapacity(32);
    mScroller = new Scroller(getContext(), new ScrollInterpolator());
    mCurrentPage = 0;
    mCenterPagesVertically = true;

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mPagingTouchSlop = configuration.getScaledPagingTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mDensity = getResources().getDisplayMetrics().density;

    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
    mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * mDensity);
    mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * mDensity);
    setOnHierarchyChangeListener(this);
}

From source file:library.slideMenu.SlideMenu.java

public void setInterpolator(Interpolator interpolator) {
    mInterpolator = interpolator;
    mScroller = new Scroller(getContext(), interpolator);
}

From source file:android.improving.utils.views.cardsview.OrientedViewPager.java

void initViewPager() {
    setWillNotDraw(false);/* ww w .  j  a  va 2 s .c  om*/
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    setFocusable(true);
    final Context context = getContext();
    mScroller = new Scroller(context, sInterpolator);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;

    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mTopLeftEdge = new EdgeEffectCompat(context);
    mRightBottomEdge = new EdgeEffectCompat(context);

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}

From source file:com.digreamon.android.widget.SlidingPaneLayout.java

public SlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mScroller = new Scroller(context, sInterpolator);
    mGutterSize = (int) dp2px(DEFAULT_GUTTER_SIZE);
    mOverhangSize = (int) dp2px(DEFAULT_OVERHANG_SIZE);

    final ViewConfiguration viewConfig = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(viewConfig);
    mMaxVelocity = viewConfig.getScaledMaximumFlingVelocity();

    setWillNotDraw(false);/*from   www .j  a v  a2s .c  o  m*/
}

From source file:com.icloud.listenbook.base.view.DraggableGridViewPager.java

private void initDraggableGridViewPager() {
    // OnDraw//ww  w .  j ava  2s .co  m
    setWillNotDraw(false);
    // ?Child View?Child View???
    setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
    // ??
    setFocusable(true);
    // ?? ??
    setChildrenDrawingOrderEnabled(true);

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

    mGridGap = (int) (DEFAULT_GRID_GAP * density);

    // internal paddings
    mPaddingLeft = getPaddingLeft();
    mPaddingTop = getPaddingTop();
    mPaddingRight = getPaddingRight();
    mPaddingButtom = getPaddingBottom();
    super.setPadding(0, 0, 0, 0);

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

    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
}

From source file:com.chenglong.muscle.ui.LazyViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*from ww  w .  j  av  a2 s  .co 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();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = new EdgeEffectCompat(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}

From source file:com.gome.ecmall.custom.VerticalViewPager.java

void initViewPager() {
    setWillNotDraw(false);/*from  w  w w  .  j ava  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();
    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);

    final float density = MobileDeviceUtil.getInstance(context.getApplicationContext()).getScreenDensity();
    mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
    mCloseEnough = (int) (CLOSE_ENOUGH * density);
    mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);

    ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}