Example usage for android.view ViewConfiguration getScaledTouchSlop

List of usage examples for android.view ViewConfiguration getScaledTouchSlop

Introduction

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

Prototype

public int getScaledTouchSlop() 

Source Link

Usage

From source file:uk.ac.kent.jb509.shopper.utils.SlidingUpPanelLayout.java

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

    final float density = context.getResources().getDisplayMetrics().density;
    mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);

    setWillNotDraw(false);/* w  ww .j ava 2  s .c om*/

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * density);

    mCanSlide = true;
    mIsSlidingEnabled = true;

    setCoveredFadeColor(DEFAULT_FADE_COLOR);

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mScrollTouchSlop = vc.getScaledTouchSlop();
}

From source file:com.example.zhangyipeng.swipelibrary.SwipeListViewTouchListener2.java

/**
 * Constructor//from   w w  w .jav  a2 s  .c om
 *
 * @param swipeListView  SwipeListView
 * @param swipeFrontView front view Identifier
 * @param swipeBackView  back view Identifier
 */
public SwipeListViewTouchListener2(SwipeListView2 swipeListView, int swipeFrontView, int swipeBackView) {
    this.swipeFrontView = swipeFrontView;
    this.swipeBackView = swipeBackView;
    ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext());
    slop = vc.getScaledTouchSlop();
    minFlingVelocity = vc.getScaledMinimumFlingVelocity();
    maxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    configShortAnimationTime = swipeListView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    animationTime = configShortAnimationTime;
    this.swipeListView = swipeListView;
}

From source file:com.fortysevendeg.swipelistview.ExpandableSwipeListViewTouchListener.java

/**
 * Constructor//w w w  .  ja v  a2s  .  co  m
 *
 * @param swipeListView  SwipeListView
 * @param swipeFrontView front view Identifier
 * @param swipeBackView  back view Identifier
 */
public ExpandableSwipeListViewTouchListener(ExpandableSwipeListView swipeListView, int swipeFrontView,
        int swipeBackView, int swipeGroupView) {
    this.swipeFrontView = swipeFrontView;
    this.swipeBackView = swipeBackView;
    this.swipeGroupView = swipeGroupView;
    ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext());
    slop = vc.getScaledTouchSlop();
    minFlingVelocity = vc.getScaledMinimumFlingVelocity();
    maxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    configShortAnimationTime = swipeListView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    animationTime = configShortAnimationTime;
    this.swipeListView = swipeListView;
}

From source file:com.praisehim.koraildelay.SwipeLibrary.SwipeListViewTouchListener.java

/**
 * Constructor// www . j  a  v a 2 s .co m
 * 
 * @param swipeListView
 *            SwipeListView
 * @param swipeFrontView
 *            front view Identifier
 * @param swipeBackView
 *            back view Identifier
 */
public SwipeListViewTouchListener(SwipeListView swipeListView, int swipeFrontView, int swipeBackView) {
    this.swipeFrontView = swipeFrontView;
    this.swipeBackView = swipeBackView;
    ViewConfiguration vc = ViewConfiguration.get(swipeListView.getContext());
    slop = vc.getScaledTouchSlop();
    minFlingVelocity = vc.getScaledMinimumFlingVelocity();
    maxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    configShortAnimationTime = swipeListView.getContext().getResources()
            .getInteger(android.R.integer.config_longAnimTime);
    animationTime = configShortAnimationTime;
    this.swipeListView = swipeListView;
}

From source file:android.support.v7ox.widget.SwitchCompat.java

/**
 * Construct a new Switch with a default style determined by the given theme attribute,
 * overriding specific style attributes as requested.
 *
 * @param context The Context that will determine this widget's theming.
 * @param attrs Specification of attributes that should deviate from the default styling.
 * @param defStyleAttr An attribute in the current theme that contains a
 *        reference to a style resource that supplies default values for
 *        the view. Can be 0 to not look for defaults.
 *///from  w  ww  .  j  a v a2  s . c o  m
public SwitchCompat(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);

    final Resources res = getResources();
    mTextPaint.density = res.getDisplayMetrics().density;

    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.SwitchCompat,
            defStyleAttr, 0);
    mThumbDrawable = a.getDrawable(R.styleable.SwitchCompat_android_thumb);
    if (mThumbDrawable != null) {
        mThumbDrawable.setCallback(this);
    }
    mTrackDrawable = a.getDrawable(R.styleable.SwitchCompat_track);
    if (mTrackDrawable != null) {
        mTrackDrawable.setCallback(this);
    }
    mTextOn = a.getText(R.styleable.SwitchCompat_android_textOn);
    mTextOff = a.getText(R.styleable.SwitchCompat_android_textOff);
    mShowText = a.getBoolean(R.styleable.SwitchCompat_showText, true);
    mThumbTextPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_thumbTextPadding, 0);
    mSwitchMinWidth = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchMinWidth, 0);
    mSwitchPadding = a.getDimensionPixelSize(R.styleable.SwitchCompat_switchPadding, 0);
    mSplitTrack = a.getBoolean(R.styleable.SwitchCompat_splitTrack, false);

    final int appearance = a.getResourceId(R.styleable.SwitchCompat_switchTextAppearance, 0);
    if (appearance != 0) {
        setSwitchTextAppearance(context, appearance);
    }

    mDrawableManager = AppCompatDrawableManager.get();

    a.recycle();

    final ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();
    mMinFlingVelocity = config.getScaledMinimumFlingVelocity();

    // Refresh display with current params
    refreshDrawableState();
    setChecked(isChecked());
}

From source file:com.example.zhangyipeng.swipelibrary.SwipeRecycleViewTouchListener.java

/**
 * Constructor/*from  w w  w . j av  a 2  s .  co m*/
 *
 * @param swipeRecycleView  SwipeListView
 * @param swipeFrontView front view Identifier
 * @param swipeBackView  back view Identifier
 */
public SwipeRecycleViewTouchListener(SwipeRecycleView swipeRecycleView, int swipeFrontView, int swipeBackView) {
    this.swipeFrontView = swipeFrontView;
    this.swipeBackView = swipeBackView;
    ViewConfiguration vc = ViewConfiguration.get(swipeRecycleView.getContext());
    slop = vc.getScaledTouchSlop();
    minFlingVelocity = vc.getScaledMinimumFlingVelocity();
    maxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    configShortAnimationTime = swipeRecycleView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    animationTime = configShortAnimationTime;
    this.swipeRecycleView = swipeRecycleView;
}

From source file:com.fortysevendeg.swipelistview.SwipeRecyclerTouchListener.java

/**
 * Constructor/* ww w .j a  va2  s  .  co  m*/
 *
 * @param swipeRecyclerView  SwipeListView
 * @param swipeFrontView front view Identifier
 * @param swipeBackView  back view Identifier
 */
public SwipeRecyclerTouchListener(SwipeRecyclerView swipeRecyclerView, int swipeFrontView, int swipeBackView) {
    this.swipeFrontView = swipeFrontView;
    this.swipeBackView = swipeBackView;
    ViewConfiguration vc = ViewConfiguration.get(swipeRecyclerView.getContext());
    slop = vc.getScaledTouchSlop();
    minFlingVelocity = vc.getScaledMinimumFlingVelocity();
    maxFlingVelocity = vc.getScaledMaximumFlingVelocity();
    configShortAnimationTime = swipeRecyclerView.getContext().getResources()
            .getInteger(android.R.integer.config_shortAnimTime);
    animationTime = configShortAnimationTime;
    this.swipeRecyclerView = swipeRecyclerView;
}

From source file:ca.mymenuapp.ui.widgets.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
                throw new IllegalArgumentException("layout_gravity must be set to either top or bottom");
            }/*  w ww  .j a va 2 s . c  o m*/
            mIsSlidingUp = gravity == Gravity.BOTTOM;
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_collapsedHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1);
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mCanSlide = true;
    mIsSlidingEnabled = true;

    ViewConfiguration vc = ViewConfiguration.get(context);
    mScrollTouchSlop = vc.getScaledTouchSlop();
}

From source file:com.lab47billion.appchooser.HorizontalPicker.java

public HorizontalPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    _context = context;//from w w w  .  jav a2 s  .co  m

    // create the selector wheel paint
    TextPaint paint = new TextPaint();
    paint.setAntiAlias(true);
    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);
        mDividerSize = a.getDimension(R.styleable.HorizontalPicker_dividerSize, mDividerSize);
        mNormalTextSize = a.getDimension(R.styleable.HorizontalPicker_normalTextSize, 20);
        mSelectedTextSize = a.getDimension(R.styleable.HorizontalPicker_selectedTextSize, -1);
        sideItems = a.getInt(R.styleable.HorizontalPicker_sideItems, sideItems);

        if (mNormalTextSize > -1) {
            setTextSize(mNormalTextSize);
        }
        if (mSelectedTextSize == -1) {
            mSelectedTextSize = mNormalTextSize;
        }

    } 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:org.mariotaku.multivalueswitch.library.MultiValueSwitch.java

/**
 * Construct a new Switch with a default style determined by the given theme attribute,
 * overriding specific style attributes as requested.
 *
 * @param context      The Context that will determine this widget's theming.
 * @param attrs        Specification of attributes that should deviate from the default styling.
 * @param defStyleAttr An attribute in the current theme that contains a
 *                     reference to a style resource that supplies default values for
 *                     the view. Can be 0 to not look for defaults.
 *//*ww  w  .j av  a  2 s. c  o m*/
@SuppressLint("PrivateResource")
public MultiValueSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
    super(MVS_TintContextWrapperAccessor.wrap(context), attrs, defStyleAttr);

    mDrawableManager = AppCompatDrawableManager.get();
    mBackgroundTintHelper = new MVS_AppCompatBackgroundHelperAccessor(this);
    mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);

    TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            android.support.v7.appcompat.R.styleable.SwitchCompat, defStyleAttr, 0);
    mThumbDrawable = a.getDrawable(android.support.v7.appcompat.R.styleable.SwitchCompat_android_thumb);
    if (mThumbDrawable != null) {
        mThumbDrawable.setCallback(this);
    }
    mTrackDrawable = a.getDrawable(android.support.v7.appcompat.R.styleable.SwitchCompat_track);
    if (mTrackDrawable != null) {
        mTrackDrawable.setCallback(this);
    }

    mPointPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPointPaint.setColor(0x33000000);
    mPointPaint.setStyle(Paint.Style.FILL);
    mPointRadius = getResources().getDisplayMetrics().density * 2;

    mSwitchMinWidth = a
            .getDimensionPixelSize(android.support.v7.appcompat.R.styleable.SwitchCompat_switchMinWidth, 0);
    mSwitchPadding = a
            .getDimensionPixelSize(android.support.v7.appcompat.R.styleable.SwitchCompat_switchPadding, 0);
    mSplitTrack = a.getBoolean(android.support.v7.appcompat.R.styleable.SwitchCompat_splitTrack, false);

    a.recycle();

    a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.MultiValueSwitch, defStyleAttr, 0);
    setMax(a.getInt(R.styleable.MultiValueSwitch_android_max, 2));
    setEntries(a.getTextArray(R.styleable.MultiValueSwitch_android_entries));
    mThumbPosition = getThumbPosition(a.getInt(R.styleable.MultiValueSwitch_android_position, 0));
    setEnabled(a.getBoolean(R.styleable.MultiValueSwitch_android_enabled, true));
    a.recycle();

    final ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();
    mMinFlingVelocity = config.getScaledMinimumFlingVelocity();

    // Refresh display with current params
    refreshDrawableState();
    setCheckedPosition(getCheckedPosition());
}