Example usage for android.content.res Resources getBoolean

List of usage examples for android.content.res Resources getBoolean

Introduction

In this page you can find the example usage for android.content.res Resources getBoolean.

Prototype

public boolean getBoolean(@BoolRes int id) throws NotFoundException 

Source Link

Document

Return a boolean associated with a particular resource ID.

Usage

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  av a  2s .c om*/

    // 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.wots.lutmaar.CustomView.CirclePageIndicator.java

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

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.white50); //Color.parseColor("#80FFFFFF"));
    final int defaultFillColor = res.getColor(R.color.white);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.white50);
    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_radius1, 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.achep.acdisplay.Config.java

/**
 * Loads saved values from shared preferences.
 * This is called on {@link App app's} create.
 */// w  ww . j av a2  s .  c om
void init(@NonNull Context context) {
    mListeners = new ArrayList<>(6);

    Resources res = context.getResources();
    SharedPreferences prefs = getSharedPreferences(context);
    mAcDisplayEnabled = prefs.getBoolean(KEY_ENABLED, res.getBoolean(R.bool.config_default_enabled));
    mKeyguardEnabled = prefs.getBoolean(KEY_KEYGUARD, res.getBoolean(R.bool.config_default_keyguard_enabled));
    mActiveMode = prefs.getBoolean(KEY_ACTIVE_MODE, res.getBoolean(R.bool.config_default_active_mode_enabled));
    mActiveModeWithoutNotifies = prefs.getBoolean(KEY_ACTIVE_MODE_WITHOUT_NOTIFICATIONS,
            res.getBoolean(R.bool.config_default_active_mode_without_notifies_enabled));

    // notifications
    mNotifyLowPriority = prefs.getBoolean(KEY_NOTIFY_LOW_PRIORITY,
            res.getBoolean(R.bool.config_default_notify_low_priority));
    mNotifyWakeUpOn = prefs.getBoolean(KEY_NOTIFY_WAKE_UP_ON,
            res.getBoolean(R.bool.config_default_notify_wake_up_on));

    // timeout
    mTimeoutNormal = prefs.getInt(KEY_TIMEOUT_NORMAL, res.getInteger(R.integer.config_default_timeout_normal));
    mTimeoutShort = prefs.getInt(KEY_TIMEOUT_SHORT, res.getInteger(R.integer.config_default_timeout_short));

    // inactive time
    mInactiveTimeFrom = prefs.getInt(KEY_INACTIVE_TIME_FROM,
            res.getInteger(R.integer.config_default_inactive_time_from));
    mInactiveTimeTo = prefs.getInt(KEY_INACTIVE_TIME_TO,
            res.getInteger(R.integer.config_default_inactive_time_to));
    mInactiveTimeEnabled = prefs.getBoolean(KEY_INACTIVE_TIME_ENABLED,
            res.getBoolean(R.bool.config_default_inactive_time_enabled));

    // interface
    mUiWallpaper = prefs.getBoolean(KEY_UI_WALLPAPER_SHOWN,
            res.getBoolean(R.bool.config_default_ui_show_wallpaper));
    mUiWallpaperShadow = prefs.getBoolean(KEY_UI_SHADOW_TOGGLE,
            res.getBoolean(R.bool.config_default_ui_show_shadow));
    mUiDynamicBackground = prefs.getInt(KEY_UI_DYNAMIC_BACKGROUND_MODE,
            res.getInteger(R.integer.config_default_ui_show_shadow_dynamic_bg));
    mUiMirroredTimeoutBar = prefs.getBoolean(KEY_UI_MIRRORED_TIMEOUT_BAR,
            res.getBoolean(R.bool.config_default_ui_mirrored_timeout_bar));
    mUiNotifyCircledIcon = prefs.getBoolean(KEY_UI_NOTIFY_CIRCLED_ICON,
            res.getBoolean(R.bool.config_default_ui_notify_circled_icon));
    mUiBatterySticky = prefs.getBoolean(KEY_UI_STATUS_BATTERY_STICKY,
            res.getBoolean(R.bool.config_default_ui_status_battery_sticky));
    mUiFullScreen = prefs.getBoolean(KEY_UI_FULLSCREEN, res.getBoolean(R.bool.config_default_ui_full_screen));
    mUiUnlockAnimation = prefs.getBoolean(KEY_UI_UNLOCK_ANIMATION,
            res.getBoolean(R.bool.config_default_ui_unlock_animation));
    mUiIconSize = prefs.getInt(KEY_UI_ICON_SIZE, res.getInteger(R.integer.config_default_ui_icon_size_dp));

    // development
    mDevSensorsDump = prefs.getBoolean(KEY_DEV_SENSORS_DUMP,
            res.getBoolean(R.bool.config_default_dev_sensors_dump));

    // other
    mEnabledOnlyWhileCharging = prefs.getBoolean(KEY_ONLY_WHILE_CHARGING,
            res.getBoolean(R.bool.config_default_enabled_only_while_charging));
    mScreenOffAfterLastNotify = prefs.getBoolean(KEY_FEEL_SCREEN_OFF_AFTER_LAST_NOTIFY,
            res.getBoolean(R.bool.config_default_feel_screen_off_after_last_notify));
    mFeelWidgetPinnable = prefs.getBoolean(KEY_FEEL_WIDGET_PINNABLE,
            res.getBoolean(R.bool.config_default_feel_widget_pinnable));
    mFeelWidgetReadable = prefs.getBoolean(KEY_FEEL_WIDGET_READABLE,
            res.getBoolean(R.bool.config_default_feel_widget_readable));

    // triggers
    mTrigHelpRead = prefs.getBoolean(KEY_TRIG_HELP_READ, false);
    mTrigTranslated = prefs.getBoolean(KEY_TRIG_TRANSLATED, false);
    mTrigPreviousVersion = prefs.getInt(KEY_TRIG_PREVIOUS_VERSION, 0);
}

From source file:com.ufo.judicature.Widget.viewpager.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.context = context;
    if (isInEditMode())
        return;//from  w w  w.ja v  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.main_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.main_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);
}

From source file:com.kerkr.edu.widget.viewpager.CircleZoomPageIndicator.java

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

    // Load defaults from resources
    final Resources res = getResources();
    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 = HORIZONTAL;/* ww  w  . j av  a2 s . c  o m*/

    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mMaxRadius = (int) (mRadius * 1.25f);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    mSelectedCorlor = a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor);
    mNormalCorlor = a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor);
    a.recycle();

    mPaintNormal = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintNormal.setStyle(Style.FILL);
    mPaintNormal.setColor(mNormalCorlor);
    mPaintCur = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintCur.setStyle(Style.FILL);
    mPaintCur.setColor(mSelectedCorlor);
    mPaintTarget = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintTarget.setStyle(Paint.Style.FILL);
    mPaintTarget.setColor(mNormalCorlor);
    mRadiusCur = mMaxRadius;
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.lovebridge.library.view.viewpagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from   ww  w.j  a v  a2s  . 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 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);
}

From source file:com.viewpagerindicator.ViewCirclePageIndicator.java

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

    // 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);
}

From source file:com.asvpdemo.AutoScrollViewPagerCirclePageIndicator.java

public AutoScrollViewPagerCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from w  w w .  j  a  v 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);
    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.viewsforandroid.foundry.sample.indicators.NumericPageIndicator.java

@SuppressWarnings("deprecation")
public NumericPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;/*from  w  ww  .  j av  a2 s .com*/
    }

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultTextColor = res.getColor(R.color.default_page_number_indicator_text_color);
    final int defaultPageNumberTextColor = res
            .getColor(R.color.default_page_number_indicator_page_number_text_color);
    final boolean defaultPageNumberTextBold = res
            .getBoolean(R.bool.default_page_number_indicator_page_number_text_bold);
    final int defaultButtonPressedColor = res
            .getColor(R.color.default_page_number_indicator_pressed_button_color);
    final float defaultTopPadding = res.getDimension(R.dimen.default_page_number_indicator_top_padding);
    final float defaultBottomPadding = res.getDimension(R.dimen.default_page_number_indicator_bottom_padding);
    final float defaultTextSize = res.getDimension(R.dimen.default_page_number_indicator_text_size);
    final boolean defaultShowChangePageButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_change_page_buttons);
    final boolean defaultShowStartEndButtons = res
            .getBoolean(R.bool.default_page_number_indicator_show_start_end_buttons);

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

    mTextTemplate = a.getString(R.styleable.NumericPageIndicator_textTemplate);
    if (mTextTemplate == null) {
        mTextTemplate = res.getString(R.string.default_page_number_indicator_text_template);
        ;
    }
    parseTextTemplate();

    mTextStartButton = a.getString(R.styleable.NumericPageIndicator_startButtonText);
    if (mTextStartButton == null) {
        mTextStartButton = res.getString(R.string.default_page_number_indicator_start_button_text);
    }
    mTextEndButton = a.getString(R.styleable.NumericPageIndicator_endButtonText);
    if (mTextEndButton == null) {
        mTextEndButton = res.getString(R.string.default_page_number_indicator_end_button_text);
    }
    mTextPreviousButton = a.getString(R.styleable.NumericPageIndicator_previousButtonText);
    if (mTextPreviousButton == null) {
        mTextPreviousButton = res.getString(R.string.default_page_number_indicator_previous_button_text);
    }
    mTextNextButton = a.getString(R.styleable.NumericPageIndicator_nextButtonText);
    if (mTextNextButton == null) {
        mTextNextButton = res.getString(R.string.default_page_number_indicator_next_button_text);
    }

    mColorText = a.getColor(R.styleable.NumericPageIndicator_android_textColor, defaultTextColor);
    mColorPageNumberText = a.getColor(R.styleable.NumericPageIndicator_pageNumberTextColor,
            defaultPageNumberTextColor);
    mPageNumberTextBold = a.getBoolean(R.styleable.NumericPageIndicator_pageNumberTextBold,
            defaultPageNumberTextBold);
    mColorPressedButton = a.getColor(R.styleable.NumericPageIndicator_pressedButtonColor,
            defaultButtonPressedColor);
    mPaddingTop = a.getDimension(R.styleable.NumericPageIndicator_android_paddingTop, defaultTopPadding);
    mPaddingBottom = a.getDimension(R.styleable.NumericPageIndicator_android_paddingBottom,
            defaultBottomPadding);
    mPaintText.setColor(mColorText);
    mShowChangePageButtons = a.getBoolean(R.styleable.NumericPageIndicator_showChangePageButtons,
            defaultShowChangePageButtons);
    mShowStartEndButtons = a.getBoolean(R.styleable.NumericPageIndicator_showStartEndButtons,
            defaultShowStartEndButtons);

    mPaintButtonBackground.setColor(mColorPressedButton);
    final float textSize = a.getDimension(R.styleable.NumericPageIndicator_android_textSize, defaultTextSize);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);

    mPaintPageNumberText.setColor(mColorPageNumberText);
    mPaintPageNumberText.setTextSize(textSize);
    mPaintPageNumberText.setAntiAlias(true);
    if (mPageNumberTextBold) {
        mPaintPageNumberText.setTypeface(Typeface.DEFAULT_BOLD);
    }

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

    a.recycle();
}

From source file:com.wj.kindergarten.ui.viewpager.CirclePageIndicator.java

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

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.translate);
    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);
}