Example usage for android.view ViewConfiguration getScaledMaximumFlingVelocity

List of usage examples for android.view ViewConfiguration getScaledMaximumFlingVelocity

Introduction

In this page you can find the example usage for android.view ViewConfiguration getScaledMaximumFlingVelocity.

Prototype

public int getScaledMaximumFlingVelocity() 

Source Link

Usage

From source file:kr.selfcontrol.selflocklauncher.picker.HorizontalPicker.java

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

    // create the selector wheel paint
    TextPaint paint = new TextPaint();
    paint.setAntiAlias(true);//from   w w w  .ja  v a 2 s  .  c  om
    mTextPaint = paint;

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

    CharSequence[] values;
    int ellipsize = 3; // END default value
    int sideItems = mSideItems;

    try {
        mTextColor = a.getColorStateList(R.styleable.HorizontalPicker_android_textColor);
        if (mTextColor == null) {
            mTextColor = ColorStateList.valueOf(0xFF000000);
        }

        values = a.getTextArray(R.styleable.HorizontalPicker_values);
        ellipsize = a.getInt(R.styleable.HorizontalPicker_android_ellipsize, ellipsize);
        mMarqueeRepeatLimit = a.getInt(R.styleable.HorizontalPicker_android_marqueeRepeatLimit,
                mMarqueeRepeatLimit);
        mDividerSize = a.getDimension(R.styleable.HorizontalPicker_dividerSize, mDividerSize);
        sideItems = a.getInt(R.styleable.HorizontalPicker_sideItems, sideItems);

        float textSize = a.getDimension(R.styleable.HorizontalPicker_android_textSize, -1);
        if (textSize > -1) {
            setTextSize(textSize);
        }
    } finally {
        a.recycle();
    }

    switch (ellipsize) {
    case 1:
        setEllipsize(TextUtils.TruncateAt.START);
        break;
    case 2:
        setEllipsize(TextUtils.TruncateAt.MIDDLE);
        break;
    case 3:
        setEllipsize(TextUtils.TruncateAt.END);
        break;
    case 4:
        setEllipsize(TextUtils.TruncateAt.MARQUEE);
        break;
    }

    Paint.FontMetricsInt fontMetricsInt = mTextPaint.getFontMetricsInt();
    mBoringMetrics = new BoringLayout.Metrics();
    mBoringMetrics.ascent = fontMetricsInt.ascent;
    mBoringMetrics.bottom = fontMetricsInt.bottom;
    mBoringMetrics.descent = fontMetricsInt.descent;
    mBoringMetrics.leading = fontMetricsInt.leading;
    mBoringMetrics.top = fontMetricsInt.top;
    mBoringMetrics.width = mItemWidth;

    setWillNotDraw(false);

    mFlingScrollerX = new OverScroller(context);
    mAdjustScrollerX = new OverScroller(context, new DecelerateInterpolator(2.5f));

    // initialize constants
    ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity()
            / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mOverscrollDistance = configuration.getScaledOverscrollDistance();

    mPreviousScrollerX = Integer.MIN_VALUE;

    setValues(values);
    setSideItems(sideItems);

    mTouchHelper = new PickerTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);

}

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  ww  w .  j a v a2 s.  c  o m*/
}

From source file:com.hb.hkm.slidinglayer.SlidLayer.java

private void init() {

    setWillNotDraw(false);/*  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);

    mRandom = new Random();
}

From source file:com.chauthai.swipereveallayout.ViewDragHelper.java

/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions./*from   w  w w  . ja v a 2s  .co m*/
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }
    mParentView = forParent;
    mCallback = cb;
    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}

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  ww  w  . j ava  2s.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:com.iterlog.swipbackhelper.ViewDragHelper.java

/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions./*  w  w w  .  j a  v  a 2  s.c  o  m*/
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);

}

From source file:com.comcast.freeflow.core.FreeFlowContainer.java

@Override
protected void init(Context context) {
    // usedViews = new HashMap<Object, FreeFlowItem>();
    // usedHeaderViews = new HashMap<Object, FreeFlowItem>();

    setWillNotDraw(false);//from ww w.j av a  2 s. co m

    viewpool = new ViewPool();
    frames = new HashMap<Object, FreeFlowItem>();

    ViewConfiguration configuration = ViewConfiguration.get(context);
    maxFlingVelocity = configuration.getScaledMaximumFlingVelocity();
    minFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    overflingDistance = configuration.getScaledOverflingDistance();
    overscrollDistance = configuration.getScaledOverscrollDistance();

    touchSlop = configuration.getScaledTouchSlop();

    scroller = new OverScroller(context);
    mLeftEdge = new EdgeEffect(context);
    mRightEdge = new EdgeEffect(context);
    mTopEdge = new EdgeEffect(context);
    mBottomEdge = new EdgeEffect(context);

}

From source file:com.cyanogenmod.filemanager.ui.widgets.ViewDragHelper.java

/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.//from   w  w w  .j  a  v  a 2s.c  o  m
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = new Scroller(context, sInterpolator);
}

From source file:com.albedinsky.android.support.ui.widget.ViewDragHelper.java

/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions./*  w w w  .ja v  a  2  s  . c  o  m*/
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    //mScroller = ScrollerCompat.create(context, sInterpolator);
    mScroller = new Scroller(context, sInterpolator);
}

From source file:com.android.ex.widget.StaggeredGridView.java

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

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.from(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);/* w  w w .  ja va  2 s. c om*/
    setClipToPadding(false);
}