List of usage examples for android.content.res Resources getInteger
public int getInteger(@IntegerRes int id) throws NotFoundException
From source file:com.blue.sky.control.CirclePageIndicator.java
@SuppressWarnings("deprecation") public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w ww.j a v a 2 s . co 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 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); final float defaultPadding = res.getDimension(R.dimen.default_circle_indicator_padding); defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, Styleable.CirclePageIndicator, defStyle, 0); indicateCircleType = a.getInt(Styleable.CirclePageIndicator_unIndicateCircleType, 0); mCentered = a.getBoolean(Styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(Styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(Styleable.CirclePageIndicator_pageColor, defaultPageColor)); if (indicateCircleType == 0) { mPaintStroke.setStyle(Style.STROKE); } else if (indicateCircleType == 1) { mPaintStroke.setStyle(Style.FILL); } mPaintStroke.setColor(a.getColor(Styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension(Styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(Styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(Styleable.CirclePageIndicator_radius, defaultRadius); padding = a.getDimension(Styleable.CirclePageIndicator_padding, defaultPadding); mSnap = a.getBoolean(Styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a.getDrawable(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.farukcankaya.rtlviewpagerindicator.CircleIndicator.java
public CircleIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w w w .j a v a2 s .com //Load defaults from resources final Resources res = 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.CircleIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CircleIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CircleIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Paint.Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CircleIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Paint.Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CircleIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CircleIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Paint.Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CircleIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CircleIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CircleIndicator_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.CircleIndicator_android_background); if (background != null) { if (Build.VERSION.SDK_INT >= 16) { setBackground(background); } else { setBackgroundDrawable(background); } } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledPagingTouchSlop(); }
From source file:com.seasonsread.app.view.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w w w . j a v a 2 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 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); 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); mPaintPageFill.setColor(context.getResources().getColor(R.color.trans_light)); mPaintStroke.setColor(context.getResources().getColor(R.color.black2)); mPaintStroke.setStrokeWidth(1); mPaintFill.setColor(context.getResources().getColor(R.color.colorPrimary)); }
From source file:com.bolaa.medical.view.banner.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(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, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.STROKE); mPaintPageFill.setStrokeWidth(1);// mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke/*from www . ja va 2 s. c o m*/ .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); 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); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:me.lizheng.deckview.helpers.DeckViewConfig.java
/** * Updates the state, given the specified context */// w w w .j a v a2 s.c om void update(Context context) { Resources res = context.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); // Debug mode debugModeEnabled = false; // Layout isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; // Insets displayRect.set(0, 0, dm.widthPixels, dm.heightPixels); // Animations animationPxMovementPerSecond = res.getDimensionPixelSize(R.dimen.animation_movement_in_dps_per_second); // Filtering filteringCurrentViewsAnimDuration = res.getInteger(R.integer.filter_animate_current_views_duration); filteringNewViewsAnimDuration = res.getInteger(R.integer.filter_animate_new_views_duration); // Task stack taskStackScrollDuration = res.getInteger(R.integer.animate_deck_scroll_duration); TypedValue widthPaddingPctValue = new TypedValue(); res.getValue(R.dimen.deck_width_padding_percentage, widthPaddingPctValue, true); taskStackWidthPaddingPct = widthPaddingPctValue.getFloat(); TypedValue stackOverscrollPctValue = new TypedValue(); res.getValue(R.dimen.deck_overscroll_percentage, stackOverscrollPctValue, true); taskStackOverscrollPct = stackOverscrollPctValue.getFloat(); taskStackMaxDim = res.getInteger(R.integer.max_deck_view_dim); taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.deck_top_padding); // Transition transitionEnterFromAppDelay = res.getInteger(R.integer.enter_from_app_transition_duration); transitionEnterFromHomeDelay = res.getInteger(R.integer.enter_from_home_transition_duration); // Task view animation and styles taskViewEnterFromAppDuration = res.getInteger(R.integer.task_enter_from_app_duration); taskViewEnterFromHomeDuration = res.getInteger(R.integer.task_enter_from_home_duration); taskViewEnterFromHomeStaggerDelay = res.getInteger(R.integer.task_enter_from_home_stagger_delay); taskViewExitToAppDuration = res.getInteger(R.integer.task_exit_to_app_duration); taskViewExitToHomeDuration = res.getInteger(R.integer.task_exit_to_home_duration); taskViewRemoveAnimDuration = res.getInteger(R.integer.animate_task_view_remove_duration); taskViewRemoveAnimTranslationXPx = res.getDimensionPixelSize(R.dimen.task_view_remove_anim_translation_x); taskViewRoundedCornerRadiusPx = res.getDimensionPixelSize(R.dimen.task_view_rounded_corners_radius); taskViewHighlightPx = res.getDimensionPixelSize(R.dimen.task_view_highlight); taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.task_view_z_min); taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.task_view_z_max); taskViewAffiliateGroupEnterOffsetPx = res .getDimensionPixelSize(R.dimen.task_view_affiliate_group_enter_offset); TypedValue thumbnailAlphaValue = new TypedValue(); res.getValue(R.dimen.task_view_thumbnail_alpha, thumbnailAlphaValue, true); taskViewThumbnailAlpha = thumbnailAlphaValue.getFloat(); // Task bar colors taskBarViewDefaultBackgroundColor = ContextCompat.getColor(context, R.color.task_bar_default_background_color); taskBarViewLightTextColor = ContextCompat.getColor(context, R.color.task_bar_light_text_color); taskBarViewDarkTextColor = ContextCompat.getColor(context, R.color.task_bar_dark_text_color); taskBarViewHighlightColor = ContextCompat.getColor(context, R.color.task_bar_highlight_color); TypedValue affMinAlphaPctValue = new TypedValue(); res.getValue(R.dimen.task_affiliation_color_min_alpha_percentage, affMinAlphaPctValue, true); taskBarViewAffiliationColorMinAlpha = affMinAlphaPctValue.getFloat(); // Task bar size & animations taskBarHeight = res.getDimensionPixelSize(R.dimen.deck_child_header_bar_height); taskBarDismissDozeDelaySeconds = res.getInteger(R.integer.task_bar_dismiss_delay_seconds); // Nav bar scrim navBarScrimEnterDuration = res.getInteger(R.integer.nav_bar_scrim_enter_duration); // Misc useHardwareLayers = res.getBoolean(R.bool.config_use_hardware_layers); altTabKeyDelay = res.getInteger(R.integer.deck_alt_tab_key_delay); fakeShadows = res.getBoolean(R.bool.config_fake_shadows); svelteLevel = res.getInteger(R.integer.deck_svelte_level); }
From source file:com.bolaa.medical.view.banner.LoopCirclePageIndicator.java
public LoopCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //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, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); // mPaintPageFill.setStrokeWidth(3);//? mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.FILL); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke//from w ww . jav a 2 s . c om .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); 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); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.bolaa.sleepingbar.view.banner.LoopCirclePageIndicator.java
public LoopCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //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, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setStrokeWidth(3);//? mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.FILL); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke//from w w w. ja v a2 s . c o m .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); 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); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.github.colinjeremie.willyoufindit.utils.pagerindicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from ww w . j av a 2 s . c o m //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = ContextCompat.getColor(getContext(), R.color.default_circle_indicator_page_color); final int defaultFillColor = ContextCompat.getColor(getContext(), R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = ContextCompat.getColor(getContext(), 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) { if (Build.VERSION.SDK_INT >= 16) { setBackground(background); } else { setBackgroundDrawable(background); } } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.taobao.luaview.view.indicator.circle.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w w w . ja v a2s . c o m //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.lv_default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.lv_default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.lv_default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.lv_default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.lv_default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.lv_default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.lv_default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.lv_default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LVCirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.LVCirclePageIndicator_lv_centered1, defaultCentered); mOrientation = a.getInt(R.styleable.LVCirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth( a.getDimension(R.styleable.LVCirclePageIndicator_lv_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.LVCirclePageIndicator_lv_radius1, defaultRadius); mSnap = a.getBoolean(R.styleable.LVCirclePageIndicator_lv_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.LVCirclePageIndicator_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;/* w w w . j a v a2s. c o m*/ // 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); }