Example usage for android.support.v4.view ViewConfigurationCompat getScaledPagingTouchSlop

List of usage examples for android.support.v4.view ViewConfigurationCompat getScaledPagingTouchSlop

Introduction

In this page you can find the example usage for android.support.v4.view ViewConfigurationCompat getScaledPagingTouchSlop.

Prototype

public static int getScaledPagingTouchSlop(ViewConfiguration config) 

Source Link

Document

Call ViewConfiguration#getScaledPagingTouchSlop() .

Usage

From source file:com.anjuke.library.uicomponent.photo.EndlessCircleIndicator.java

public EndlessCircleIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/* w  w  w .  ja  v a2  s  .com*/
    //Load defaults from resources
    final Resources res = getResources();

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EndlessCircleIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.EndlessCircleIndicator_centered, true);
    mOrientation = a.getInt(R.styleable.EndlessCircleIndicator_android_orientation, 0);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill
            .setColor(a.getColor(R.styleable.EndlessCircleIndicator_pageColor, Color.parseColor("#00000000")));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(
            a.getColor(R.styleable.EndlessCircleIndicator_strokeColor, Color.parseColor("#FFDDDDDD")));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.EndlessCircleIndicator_strokeWidth,
            UIUtils.dipToPx(res.getDisplayMetrics(), 1)));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill
            .setColor(a.getColor(R.styleable.EndlessCircleIndicator_fillColor, Color.parseColor("#FFFFFFFF")));
    mRadius = a.getDimension(R.styleable.EndlessCircleIndicator_radius,
            UIUtils.dipToPx(res.getDisplayMetrics(), 3));
    mSnap = a.getBoolean(R.styleable.EndlessCircleIndicator_snap, false);

    Drawable background = a.getDrawable(R.styleable.EndlessCircleIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:org.taptwo.android.widget.CircleIndicator.java

public CircleIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*  w  w  w  . j a va2 s. c  om*/
    // Retrieve styles attributs
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleIndicator);

    // Gets the inactive circle type, defaulting to "fill"
    int activeType = a.getInt(R.styleable.CircleIndicator_activeType, STYLE_FILL);

    int activeDefaultColor = 0xFFFFFFFF;

    // Get a custom inactive color if there is one
    int activeColor = a.getColor(R.styleable.CircleIndicator_activeColor, activeDefaultColor);

    // Gets the inactive circle type, defaulting to "stroke"
    int inactiveType = a.getInt(R.styleable.CircleIndicator_inactiveType, STYLE_STROKE);

    int inactiveDefaultColor = 0x44FFFFFF;
    // Get a custom inactive color if there is one
    int inactiveColor = a.getColor(R.styleable.CircleIndicator_inactiveColor, inactiveDefaultColor);

    // Retrieve the radius
    mRadius = a.getDimension(R.styleable.CircleIndicator_radius, 4.0f);
    mActiveRadius = a.getDimension(R.styleable.CircleIndicator_activeRadius, 0.5f);
    mCentered = a.getBoolean(R.styleable.CircleIndicator_centered, true);

    mOrientation = a.getInt(R.styleable.CircleIndicator_android_orientation, HORIZONTAL);
    mSnap = a.getBoolean(R.styleable.CircleIndicator_snap, false);

    mStroke = a.getBoolean(R.styleable.CircleIndicator_stroke, false);

    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CircleIndicator_strokeColor, Color.parseColor("#FFDDDDDD")));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CircleIndicator_strokeWidth, 2.5f));

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    initColors(activeColor, inactiveColor, activeType, inactiveType);
}

From source file:com.leeon.blank.widget.RangeBarNew.java

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

    applyConfig(context, attrs);/* ww w  .ja  v a2 s . com*/

    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration.get(context));

    mPaddingRect = new Rect();
    mLeftCursorRect = new Rect();
    mRightCursorRect = new Rect();
    mLeftIndicatorRect = new Rect();
    mRightIndicatorRect = new Rect();

    mPaddingRect.left = getPaddingLeft();
    mPaddingRect.top = getPaddingTop();
    mPaddingRect.right = getPaddingRight();
    mPaddingRect.bottom = getPaddingBottom();

    mRangeBarRect = new RectF();
    mRangeBarRectSelected = new RectF();

    if (mTextArray != null) {
        mTextWidthArray = new float[mTextArray.length];
    }

    mLeftScroller = new Scroller(context);
    mRightScroller = new Scroller(context);

    initPaint();
    initTextWidthArray();

    setWillNotDraw(false);
    setFocusable(true);
    setClickable(true);
}

From source file:com.slidinglayer.SlidingPanel.java

private void init() {
    setWillNotDraw(false);//  w ww .j a  v a  2s. c om
    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.maedi.user.godok.v1.viewpagerindicator.LinePageIndicator.java

@SuppressWarnings("deprecation")
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from www.j  a  v a  2  s .  c om

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res
            .getColor(com.viewpagerindicator.R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res
            .getColor(com.viewpagerindicator.R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res
            .getDimension(com.viewpagerindicator.R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res
            .getDimension(com.viewpagerindicator.R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res
            .getDimension(com.viewpagerindicator.R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res
            .getBoolean(com.viewpagerindicator.R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, com.viewpagerindicator.R.styleable.LinePageIndicator,
            defStyle, 0);

    mCentered = a.getBoolean(com.viewpagerindicator.R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(com.viewpagerindicator.R.styleable.LinePageIndicator_lineWidth,
            defaultLineWidth);
    mGapWidth = a.getDimension(com.viewpagerindicator.R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(com.viewpagerindicator.R.styleable.LinePageIndicator_strokeWidth,
            defaultStrokeWidth));
    mPaintUnselected.setColor(a.getColor(com.viewpagerindicator.R.styleable.LinePageIndicator_unselectedColor,
            defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(com.viewpagerindicator.R.styleable.LinePageIndicator_selectedColor,
            defaultSelectedColor));

    Drawable background = a
            .getDrawable(com.viewpagerindicator.R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.bairutai.openwidget.CirclePageIndicator.java

@SuppressWarnings("deprecation")
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from   w ww. j  a va 2s . c o  m

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.white);
    final int defaultFillColor = res.getColor(R.color.orange);
    final int defaultStrokeColor = res.getColor(R.color.baihui);
    final int defaultOrientation = 0;
    final float defaultStrokeWidth = 1;
    final float defaultRadius = 10;
    final boolean defaultCentered = true;
    final boolean defaultSnap = false;

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.adkdevelopment.e_contact.utils.UnderlinePageIndicator.java

@TargetApi(Build.VERSION_CODES.M)
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*  w w  w  .j av a  2 s  . c  o m*/

    final Resources res = getResources();

    //Load defaults from resources
    final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);

    int defaultSelectedColor;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        defaultSelectedColor = res.getColor(R.color.white, context.getTheme());
    } else {
        //noinspection deprecation
        defaultSelectedColor = res.getColor(R.color.white);
    }

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0);

    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

    mCornerRadius = a.getDimension(R.styleable.UnderlinePageIndicator_vpi_corner_radius, 0);

    Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background);
    if (background != null) {
        setBackground(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:yang.mobile.widget.viewpager.LoopPageIndicator.java

public LoopPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from  ww w .j a v a2 s. c o m
    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    stokenWidth = defaultStrokeWidth;

    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    stokenWidth = a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.travel.ac.view.UnderlinePageIndicator.java

public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from   w  ww  .ja  v  a 2 s .  c o m*/

    final Resources res = getResources();
    mTextPaint.setColor(Color.BLACK);
    mTextPaint.setStrokeWidth(5);
    mTextPaint.setTextSize(40);
    //Load defaults from resources
    final float defaultLineHeight = res.getInteger(R.integer.default_line_height);
    final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0);

    mTabLineHeight = a.getFloat(R.styleable.UnderlinePageIndicator_tab_line_height, defaultLineHeight);
    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

    Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }
    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.android.nobug.view.viewpager.indicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from  ww w .  j  a v  a  2s  .c om

    final int defaultPageColor = ContextCompat.getColor(context, android.R.color.darker_gray);
    final int defaultFillColor = ContextCompat.getColor(context, android.R.color.white);
    final int defaultOrientation = 0;
    final int defaultStrokeColor = ContextCompat.getColor(context, android.R.color.transparent);
    final float defaultStrokeWidth = 9;
    final float defaultRadius = 15;
    final boolean defaultCentered = true;
    final boolean defaultSnap = false;

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

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_indicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_indicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke
            .setColor(a.getColor(R.styleable.CirclePageIndicator_indicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(
            a.getDimension(R.styleable.CirclePageIndicator_indicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_indicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_indicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_indicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}