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.maedi.user.godok.v1.viewpagerindicator.CirclePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res
            .getInteger(com.viewpagerindicator.R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res
            .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res
            .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res
            .getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_snap);

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

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

    Drawable background = a
            .getDrawable(com.viewpagerindicator.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.qifeng.theunderseaworld.view.CirclePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res
            .getInteger(com.viewpagerindicator.R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res
            .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res
            .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res
            .getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_snap);

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

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

    Drawable background = a
            .getDrawable(com.viewpagerindicator.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:net.fastvan.indicator.CirclePageIndicator.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//www  .  java2  s . com

    //        public static final int getColor(Context context, int id) {
    //            final int version = Build.VERSION.SDK_INT;
    //            if (version >= 23) {
    //                return ContextCompat.getColor(context, id);
    //            } else {
    //                return context.getResources().getColor(id);
    //            }
    //        }
    //Load defaults from resources
    final Resources res = context.getResources();

    final int defaultPageColor = ContextCompat.getColor(context, R.color.default_circle_indicator_page_color);

    final int defaultFillColor = ContextCompat.getColor(context, R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = ContextCompat.getColor(context,
            R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    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));
    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) {

        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            setBackgroundDrawable(background);
        } else {
            setBackground(background);
        }
    }

    a.recycle();

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

From source file:info.ipeanut.youngsamples.third.viewgroup.directionalViewPager.DirectionalViewPager.java

void initViewPager() {
    ////from w  ww  .  j a  v  a2  s  . c o  m
    setWillNotDraw(false);
    mScroller = new Scroller(getContext());
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();//Fling
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    //crush
    //        setPageTransformer(false,new DefaultTransformer());
}

From source file:cpi.suhaib.extendedcirclepagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from  ww  w  . jav a 2s .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 int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    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));
    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);
    mMaxIndicators = a.getInt(R.styleable.CirclePageIndicator_maxIndicators, 0);
    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    Drawable nextDrawable = a.getDrawable(R.styleable.CirclePageIndicator_more_ahead_icon);
    Drawable previousDrawable = a.getDrawable(R.styleable.CirclePageIndicator_more_back_icon);

    a.recycle();

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

    if (nextDrawable != null && nextDrawable instanceof BitmapDrawable) {
        mNextIcon = ((BitmapDrawable) nextDrawable).getBitmap();
    } else {
        mNextIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_walkthrough_next);
    }
    if (previousDrawable != null && previousDrawable instanceof BitmapDrawable) {
        mPreviousIcon = ((BitmapDrawable) previousDrawable).getBitmap();
    } else {
        mPreviousIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_walkthrough_previous);
    }

    mHiddenDots = new ArrayList<>();
}

From source file:no.srib.app.client.view.CircleIshPageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res
            .getInteger(com.viewpagerindicator.R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res
            .getColor(com.viewpagerindicator.R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res
            .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res
            .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res
            .getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_snap);

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

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

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

    a.recycle();

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

    circle = BitmapFactory.decodeResource(res, R.drawable.ic_viewpager);
    selected = BitmapFactory.decodeResource(res, R.drawable.ic_viewpager_selected);
}

From source file:com.juick.android.MessagesFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final ViewConfiguration configuration = ViewConfiguration.get(getActivity());
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    databaseGetter = new Utils.ServiceGetter<DatabaseService>(getActivity(), DatabaseService.class);
    handler = new Handler();
    sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    trackLastRead = sp.getBoolean("lastReadMessages", true);
    alternativeLongClick = sp.getBoolean("alternativeLongClick", false);

    Bundle args = getArguments();/*from   w  ww.  ja v  a  2s.  c  o  m*/

    if (args != null) {
        messagesSource = (MessagesSource) args.getSerializable("messagesSource");
    }

    if (messagesSource == null)
        messagesSource = new JuickCompatibleURLMessagesSource(getActivity(), "dummy");
    if (messagesSource.getContext() == null)
        messagesSource.setContext(JuickAdvancedApplication.instance);
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);

    if (Build.VERSION.SDK_INT >= 8) {
        mScaleDetector = new ScaleGestureDetector(getActivity(), new ScaleListener());
    }

}

From source file:com.tandong.sa.vpic.UnderlinePageIndicator.java

public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from www  . ja  v a  2s. co m

    final Resources res = getResources();

    // Load defaults from resources
    final boolean defaultFades = res.getBoolean(getResources()
            .getIdentifier("default_underline_indicator_fades", "bool", context.getPackageName()));
    // final boolean defaultFades = res
    // .getBoolean(R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res.getInteger(getResources()
            .getIdentifier("default_underline_indicator_fade_delay", "integer", context.getPackageName()));
    // final int defaultFadeDelay = res
    // .getInteger(R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res.getInteger(getResources()
            .getIdentifier("default_underline_indicator_fade_length", "integer", context.getPackageName()));
    // final int defaultFadeLength = res
    // .getInteger(R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res.getColor(getResources()
            .getIdentifier("default_underline_indicator_selected_color", "color", context.getPackageName()));
    // final int defaultSelectedColor = res
    // .getColor(R.color.default_underline_indicator_selected_color);

    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] {
            getResources().getIdentifier("UnderlinePageIndicator", "styleable", context.getPackageName()) },
            defStyle, 0);
    // TypedArray a = context.obtainStyledAttributes(attrs,
    // R.styleable.UnderlinePageIndicator, defStyle, 0);

    setFades(a.getBoolean(
            getResources().getIdentifier("UnderlinePageIndicator_fades", "styleable", context.getPackageName()),
            defaultFades));
    // setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades,
    // defaultFades));
    setSelectedColor(a.getColor(getResources().getIdentifier("UnderlinePageIndicator_selectedColor",
            "styleable", context.getPackageName()), defaultSelectedColor));
    // setSelectedColor(a.getColor(
    // R.styleable.UnderlinePageIndicator_selectedColor,
    // defaultSelectedColor));
    setFadeDelay(a.getInteger(getResources().getIdentifier("UnderlinePageIndicator_fadeDelay", "styleable",
            context.getPackageName()), defaultFadeDelay));
    // setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay,
    // defaultFadeDelay));
    setFadeLength(a.getInteger(getResources().getIdentifier("UnderlinePageIndicator_fadeLength", "styleable",
            context.getPackageName()), defaultFadeLength));
    // setFadeLength(a.getInteger(
    // R.styleable.UnderlinePageIndicator_fadeLength,
    // defaultFadeLength));

    Drawable background = a.getDrawable(getResources()
            .getIdentifier("UnderlinePageIndicator_android_background", "styleable", context.getPackageName()));
    // 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:ru.phplego.core.etc.viewpagerindicator.CirclePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_circle_indicator_page_color"));
    final int defaultFillColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_circle_indicator_fill_color"));
    final int defaultOrientation = res.getInteger(Res.getId(Application.getContext().getPackageName(),
            "integer", "default_circle_indicator_orientation"));
    final int defaultStrokeColor = res.getColor(Res.getId(Application.getContext().getPackageName(), "color",
            "default_circle_indicator_stroke_color"));
    final float defaultStrokeWidth = res.getDimension(Res.getId(Application.getContext().getPackageName(),
            "dimen", "default_circle_indicator_stroke_width"));
    final float defaultRadius = res.getDimension(
            Res.getId(Application.getContext().getPackageName(), "dimen", "default_circle_indicator_radius"));
    final boolean defaultCentered = res.getBoolean(
            Res.getId(Application.getContext().getPackageName(), "bool", "default_circle_indicator_centered"));
    final boolean defaultSnap = res.getBoolean(
            Res.getId(Application.getContext().getPackageName(), "bool", "default_circle_indicator_snap"));

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs,
            Res.getIds(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator"), defStyle,
            Res.getId(Application.getContext().getPackageName(), "style", "Widget_CirclePageIndicator"));

    mCentered = a.getBoolean(// w  ww.j a va 2 s . c  o m
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_centered"),
            defaultCentered);
    mOrientation = a.getInt(Res.getId(Application.getContext().getPackageName(), "styleable",
            "CirclePageIndicator_orientation"), defaultOrientation);
    mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_pageColor"),
            defaultPageColor));
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(Res.getId(Application.getContext().getPackageName(), "styleable",
            "CirclePageIndicator_strokeColor"), defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(Res.getId(Application.getContext().getPackageName(), "styleable",
            "CirclePageIndicator_strokeWidth"), defaultStrokeWidth));
    mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_fillColor"),
            defaultFillColor));
    mRadius = a.getDimension(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_radius"),
            defaultRadius);
    mSnap = a.getBoolean(
            Res.getId(Application.getContext().getPackageName(), "styleable", "CirclePageIndicator_snap"),
            defaultSnap);

    a.recycle();

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

From source file:flax.baseview.CirclePageIndicator.java

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

    // 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 int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final int defaultCurrentStrokeColor = res.getColor(R.color.default_circle_indicator_current_stroke_color);
    final float defaultCurrentStrokeWidth = res
            .getDimension(R.dimen.default_circle_indicator_current_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final float defaultCurrentRadius = res.getDimension(R.dimen.default_circle_indicator_current_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));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintCurrentStroke.setStyle(Style.STROKE);
    mPaintCurrentStroke.setColor(
            a.getColor(R.styleable.CirclePageIndicator_currentStrokeColor, defaultCurrentStrokeColor));
    mPaintCurrentStroke.setStrokeWidth(
            a.getDimension(R.styleable.CirclePageIndicator_currentStrokeWidth, defaultCurrentStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mCurrentRadius = a.getDimension(R.styleable.CirclePageIndicator_currentRadius, defaultCurrentRadius);
    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);
}