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.support.design.widget.NavigationDrawerView.java

public NavigationDrawerView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    // Custom attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationDrawerView, defStyleAttr,
            R.style.Widget_Design_NavigationDrawerView);

    //noinspection deprecation
    setBackgroundDrawable(a.getDrawable(R.styleable.NavigationDrawerView_android_background));
    ViewCompat.setElevation(this,
            a.getDimensionPixelSize(R.styleable.NavigationDrawerView_android_elevation, 0));
    ViewCompat.setFitsSystemWindows(this,
            a.getBoolean(R.styleable.NavigationDrawerView_android_fitsSystemWindows, false));
    mMaxWidth = a.getDimensionPixelSize(R.styleable.NavigationDrawerView_android_maxWidth, 0);
    a.recycle();//from   w  w w  .  j  a  v  a2  s .  c  o  m

    // Set up the menu
    mMenu = new MenuBuilder(context);
    mMenu.setCallback(new MenuBuilder.Callback() {
        @Override
        public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) {
            return mListener != null && mListener.onNavigationItemSelected(item);
        }

        @Override
        public void onMenuModeChange(MenuBuilder menu) {

        }
    });
    mPresenter = new NavigationMenuPresenter();
    mPresenter.setId(PRESENTER_NAVIGATION_DRAWER_VIEW);
    mPresenter.initForMenu(context, mMenu);
    mMenu.addMenuPresenter(mPresenter);
    addView((View) mPresenter.getMenuView(this));
}

From source file:com.augustopicciani.drawablepageindicator.widget.DrawablePagerIndicator.java

public DrawablePagerIndicator(Context context, AttributeSet attrs) {

    super(context, attrs);
    this.mContext = context;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawablePagerIndicator, 0, 0);
    drawableSelectedId = a.getResourceId(R.styleable.DrawablePagerIndicator_drawableSelected,
            R.drawable.ic_slider_on);/*from   w  ww . j a v  a2 s .  c  o m*/
    drawableDefaultId = a.getResourceId(R.styleable.DrawablePagerIndicator_drawableDefault,
            R.drawable.ic_slider_off);
    imageSpacing = a.getInteger(R.styleable.DrawablePagerIndicator_imageSpacing, 0);
    this.mCentered = a.getBoolean(R.styleable.DrawablePagerIndicator_centered, false);
    a.recycle();

}

From source file:com.bitants.wally.views.swipeclearlayout.SwipeClearLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * @param context//from  w w w  .  j a  v  a 2 s .  c om
 * @param attrs
 */
public SwipeClearLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    final DisplayMetrics metrics = getResources().getDisplayMetrics();

    circle = generateCircle(context, attrs, metrics);
    progressBar = new ProgressBar(context, attrs);

    decelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    accelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    initAttrs(context, attrs);
    a.recycle();
}

From source file:am.widget.scalerecyclerview.ScaleRecyclerView.java

private void initView(Context context, @Nullable AttributeSet attrs) {
    final TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.ScaleRecyclerView);
    mScaleEnable = custom.getBoolean(R.styleable.ScaleRecyclerView_srvScaleEnable, false);
    mScale = custom.getFloat(R.styleable.ScaleRecyclerView_srvScale, 1);
    mMinScale = custom.getFloat(R.styleable.ScaleRecyclerView_srvMinScale, 0.000000001f);
    mMaxScale = custom.getFloat(R.styleable.ScaleRecyclerView_srvMaxScale, 6);
    custom.recycle();/*from  w w w .j a  v  a  2  s  .  com*/
    mGestureDetector = new GestureDetectorCompat(context, new DoubleTapListener());
    mScaleGestureDetector = new ScaleGestureDetector(context, new ScaleListener());
}

From source file:com.augustopicciani.drawablepageindicator.widget.DrawablePagerIndicator.java

public DrawablePagerIndicator(Context context, AttributeSet attrs, int defStyleAttr) {

    super(context, attrs, defStyleAttr);
    this.mContext = context;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawablePagerIndicator, defStyleAttr, 0);
    drawableSelectedId = a.getResourceId(R.styleable.DrawablePagerIndicator_drawableSelected,
            R.drawable.ic_slider_on);/*from   w  w w  .j  a v  a  2  s.  c om*/
    drawableDefaultId = a.getResourceId(R.styleable.DrawablePagerIndicator_drawableDefault,
            R.drawable.ic_slider_off);
    imageSpacing = a.getInteger(R.styleable.DrawablePagerIndicator_imageSpacing, 0);
    this.mCentered = a.getBoolean(R.styleable.DrawablePagerIndicator_centered, false);

    a.recycle();

}

From source file:com.example1.ui.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from w ww .j av  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);
    final float defaultExtraSpace = res.getDimension(R.dimen.default_circle_indicator_extraspace_width);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);
    mExtraSpace = a.getDimension(R.styleable.CirclePageIndicator_extraSpace, defaultExtraSpace);
    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered1, 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.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/*  www  . j a  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:com.camnter.easyrecyclerviewsidebar.EasyRecyclerViewSidebar.java

private void init(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.EasyRecyclerViewSidebar);
    this.fontColor = typedArray.getColor(R.styleable.EasyRecyclerViewSidebar_easySidebarFontColor,
            DEFAULT_FONT_COLOR);//from  w  w  w  . j  a v  a2 s.c  o m
    this.viewBackground = typedArray.getColor(R.styleable.EasyRecyclerViewSidebar_easySidebarBackground,
            DEFAULT_VIEW_BACKGROUND);
    this.touchWrapArea = typedArray.getBoolean(R.styleable.EasyRecyclerViewSidebar_easySidebarTouchWrapArea,
            DEFAULT_ON_TOUCH_WRAP_DRAW_AREA);
    this.initOtherAttributes();
    this.initPaints();
    this.initLetterAndImageAttributes();
    typedArray.recycle();
}

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  w w .ja  va 2s.co 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.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/* ww  w  .jav  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);
}