Example usage for android.content.res TypedArray getBoolean

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

Introduction

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

Prototype

public boolean getBoolean(@StyleableRes int index, boolean defValue) 

Source Link

Document

Retrieve the boolean value for the attribute at index.

Usage

From source file:android.hqs.view.pager.indicator.LinePageIndicator.java

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

    final Resources res = getResources();

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

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

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

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setBackground(background);
        } else {
            setBackgroundDrawable(background);
        }
    }

    a.recycle();

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

From source file:cn.com.hgh.view.SlideSwitch.java

public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    listener = null;// w w w  .  ja v  a2  s .  c  o m
    paint = new Paint();
    paint.setAntiAlias(true);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch);
    color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME);
    isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false);
    shape = a.getInt(R.styleable.slideswitch_shape1, SHAPE_RECT);
    a.recycle();

}

From source file:com.efan.notlonely_android.view.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); //
    removeAllViews();/*ww w.ja va  2  s  .c  o m*/
    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_disableViewPager,
                    false);
            disableTensileSlidingBlock = attrsTypedArray
                    .getBoolean(R.styleable.PagerSlidingTabStrip_disableTensileSlidingBlock, false);
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.example.test2969mediabrowser.UnderlinePageIndicator.java

public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//  www  .ja  va 2  s. com

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

    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    mColorSelected = a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor);//joe

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

    //==================joe add 20150918===============
    defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);//joe
    mPaintText.setTextSize(res.getDimension(R.dimen.default_title_indicator_text_size));
    mPaintText.setAntiAlias(true);
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterLine.setStrokeWidth(defaultFooterLineHeight);
    mPaintFooterLine.setColor(getResources().getColor(R.color.blue_select));
    //==================joe add 20150918 end===============

    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.androtex.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 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);
    mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke//from  w  w w. ja  v a  2s .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();
}

From source file:com.cjj.viewpagerlibrary.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setHorizontalScrollBarEnabled(false); //??????

    if (attrs != null) {
        TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
        if (attrsTypedArray != null) {
            allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false);
            slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock);
            disableViewPager = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_disableViewPager,
                    false);//from   ww  w  . j av a  2s  .  c  o m
            attrsTypedArray.recycle();
        }
    }
}

From source file:com.facebook.LoginButton.java

private void parseAttributes(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_login_view);
    confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_confirm_logout, true);
    fetchUserInfo = a.getBoolean(R.styleable.com_facebook_login_view_fetch_user_info, true);
    loginText = a.getString(R.styleable.com_facebook_login_view_login_text);
    logoutText = a.getString(R.styleable.com_facebook_login_view_logout_text);
    a.recycle();/*from www  .  java  2s.c o m*/

}

From source file:com.alboteanu.android.sunshine.app.ForecastFragment.java

@Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0);
    mChoiceMode = a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE);
    mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false);
    mHoldForTransition = a.getBoolean(R.styleable.ForecastFragment_sharedElementTransitions, false);
    a.recycle();/*from w ww . j ava2  s . c  o  m*/
}

From source file:com.dev.nutclass.view.pager.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/* w  w  w. ja va2 s.c om*/

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.circle_page_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.circle_page_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.circle_page_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.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);
    interval = mRadius * 4;
}

From source file:com.boha.malengagolf.library.util.PagerTitleStrip22.java

public PagerTitleStrip22(Context context, AttributeSet attrs) {
    super(context, attrs);

    addView(mPrevText = new TextView(context));
    addView(mCurrText = new TextView(context));
    addView(mNextText = new TextView(context));

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    final int textAppearance = a.getResourceId(0, 0);
    if (textAppearance != 0) {
        mPrevText.setTextAppearance(context, textAppearance);
        mCurrText.setTextAppearance(context, textAppearance);
        mNextText.setTextAppearance(context, textAppearance);
    }/*w  ww  . j a  va 2 s. c  o  m*/
    final int textSize = a.getDimensionPixelSize(1, 0);
    if (textSize != 0) {
        setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    }
    if (a.hasValue(2)) {
        final int textColor = a.getColor(2, 0);
        mPrevText.setTextColor(textColor);
        mCurrText.setTextColor(textColor);
        mNextText.setTextColor(textColor);
    }
    mGravity = a.getInteger(3, Gravity.BOTTOM);
    a.recycle();

    mTextColor = mCurrText.getTextColors().getDefaultColor();
    setNonPrimaryAlpha(SIDE_ALPHA);

    mPrevText.setEllipsize(TruncateAt.END);
    mCurrText.setEllipsize(TruncateAt.END);
    mNextText.setEllipsize(TruncateAt.END);

    boolean allCaps = false;
    if (textAppearance != 0) {
        final TypedArray ta = context.obtainStyledAttributes(textAppearance, TEXT_ATTRS);
        allCaps = ta.getBoolean(0, false);
        ta.recycle();
    }

    if (allCaps) {
        setSingleLineAllCaps(mPrevText);
        setSingleLineAllCaps(mCurrText);
        setSingleLineAllCaps(mNextText);
    } else {
        mPrevText.setSingleLine();
        mCurrText.setSingleLine();
        mNextText.setSingleLine();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    mScaledTextSpacing = (int) (TEXT_SPACING * density);
}