Example usage for android.content.res TypedArray getInteger

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

Introduction

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

Prototype

public int getInteger(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:com.viewpagerindicator.as.library.indicator.RecyclerUnderlinePageIndicator.java

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

    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);
    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));
    setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

    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.todev.rabbitmqmanagement.ui.overview.widget.MessagesIndicator.java

protected void initializeAttributes(Context context, AttributeSet attrs) {
    TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MessagesIndicator, 0, 0);

    try {/*from  ww w .j  av  a 2 s  .c  o  m*/
        title = array.getString(R.styleable.MessagesIndicator_title);

        defaultColor = ContextCompat.getColor(context, android.R.color.black);

        valuesVisible = array.getBoolean(R.styleable.MessagesIndicator_values_visible,
                getResources().getBoolean(R.bool.queued_messages_indicator_default_values_visible));

        idleText = array.getString(R.styleable.MessagesIndicator_idle_text);

        int range = array.getInteger(R.styleable.MessagesIndicator_visible_range, 0);

        visibleRange = VisibleRange.fromRange(range);
    } finally {
        array.recycle();
    }
}

From source file:de.mrapp.android.preference.ColorPalettePreference.java

/**
 * Obtains the shape, which should be used to preview colors in the preference's dialog, from a
 * specific typed array./*from w ww .  ja va2  s  .c  o  m*/
 *
 * @param typedArray
 *         The typed array, the shape should be obtained from, as an instance of the class
 *         {@link TypedArray}. The typed array may not be null
 */
private void obtainDialogPreviewShape(@NonNull final TypedArray typedArray) {
    int defaultValue = getContext().getResources()
            .getInteger(R.integer.color_palette_preference_default_dialog_preview_shape);
    setDialogPreviewShape(PreviewShape.fromValue(
            typedArray.getInteger(R.styleable.ColorPalettePreference_dialogPreviewShape, defaultValue)));
}

From source file:com.futureinst.viewpagerindicator.UnderlinePageIndicator.java

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

    final Resources res = getResources();

    //Load defaults from resources
    final boolean defaultFades = res.getBoolean(com.futureinst.R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res
            .getInteger(com.futureinst.R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res
            .getInteger(com.futureinst.R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res
            .getColor(com.futureinst.R.color.default_underline_indicator_selected_color);

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

    setFades(a.getBoolean(com.futureinst.R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(
            a.getColor(com.futureinst.R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(com.futureinst.R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(
            a.getInteger(com.futureinst.R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

    Drawable background = a.getDrawable(com.futureinst.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.github.nitrico.mapviewpager.MapViewPager.java

private void initialize(Context context, AttributeSet attrs) {
    mapOffset = dp(32);/*from www. ja va  2  s  .co  m*/
    if (attrs != null) {
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MapViewPager, 0, 0);
        try {
            markersAlpha = a.getFloat(R.styleable.MapViewPager_markersAlpha, DEFAULT_ALPHA);
            pagerWeight = a.getInteger(R.styleable.MapViewPager_viewPagerWeight, 1);
            mapWeight = a.getInteger(R.styleable.MapViewPager_mapWeight, 1);
            mapGravity = a.getInteger(R.styleable.MapViewPager_mapGravity, 1);
            mapOffset = a.getDimensionPixelSize(R.styleable.MapViewPager_mapOffset, mapOffset);
            mapPaddingLeft = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingLeft, 0);
            mapPaddingTop = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingTop, 0);
            mapPaddingRight = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingRight, 0);
            mapPaddingBottom = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingBottom, 0);
        } finally {
            a.recycle();
        }
    }
    LayoutInflater inflater = LayoutInflater.from(context);
    switch (mapGravity) {
    case 0:
        inflater.inflate(R.layout.mapviewpager_left, this);
        break;
    case 1:
        inflater.inflate(R.layout.mapviewpager_top, this);
        break;
    case 2:
        inflater.inflate(R.layout.mapviewpager_right, this);
        break;
    case 3:
        inflater.inflate(R.layout.mapviewpager_bottom, this);
        break;
    }
}

From source file:com.maedi.user.godok.v1.viewpagerindicator.UnderlinePageIndicator.java

@SuppressWarnings("deprecation")
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;// w  w  w .  j  av  a2  s.c om

    final Resources res = getResources();

    //Load defaults from resources
    final boolean defaultFades = res
            .getBoolean(com.viewpagerindicator.R.bool.default_underline_indicator_fades);
    final int defaultFadeDelay = res
            .getInteger(com.viewpagerindicator.R.integer.default_underline_indicator_fade_delay);
    final int defaultFadeLength = res
            .getInteger(com.viewpagerindicator.R.integer.default_underline_indicator_fade_length);
    final int defaultSelectedColor = res
            .getColor(com.viewpagerindicator.R.color.default_underline_indicator_selected_color);

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

    setFades(a.getBoolean(com.viewpagerindicator.R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(com.viewpagerindicator.R.styleable.UnderlinePageIndicator_selectedColor,
            defaultSelectedColor));
    setFadeDelay(a.getInteger(com.viewpagerindicator.R.styleable.UnderlinePageIndicator_fadeDelay,
            defaultFadeDelay));
    setFadeLength(a.getInteger(com.viewpagerindicator.R.styleable.UnderlinePageIndicator_fadeLength,
            defaultFadeLength));

    Drawable background = a
            .getDrawable(com.viewpagerindicator.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.hippo.widget.Slider.java

@SuppressWarnings("deprecation")
private void init(Context context, AttributeSet attrs) {
    mContext = context;//from  www.j  av  a  2 s.c o  m
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextAlign(Paint.Align.CENTER);

    Resources resources = context.getResources();
    mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width);
    mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height);

    mBubble = new BubbleView(context, textPaint);
    mBubble.setScaleX(0.0f);
    mBubble.setScaleY(0.0f);
    AbsoluteLayout absoluteLayout = new AbsoluteLayout(context);
    absoluteLayout.addView(mBubble);
    absoluteLayout.setBackgroundDrawable(null);
    mPopup = new PopupWindow(absoluteLayout);
    mPopup.setOutsideTouchable(false);
    mPopup.setTouchable(false);
    mPopup.setFocusable(false);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider);
    textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE));
    textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12));

    updateTextSize();

    setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0));
    setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0));
    mThickness = a.getDimension(R.styleable.Slider_thickness, 2);
    mRadius = a.getDimension(R.styleable.Slider_radius, 6);
    setColor(a.getColor(R.styleable.Slider_color, Color.BLACK));

    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000);

    a.recycle();

    mProgressAnimation = new ValueAnimator();
    mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
    mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawPercent = value;
            mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value));
            updateBubblePosition();
            mBubble.setProgress(mDrawProgress);
            invalidate();
        }
    });

    mBubbleScaleAnimation = new ValueAnimator();
    mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mDrawBubbleScale = value;
            mBubble.setScaleX(value);
            mBubble.setScaleY(value);
            invalidate();
        }
    });
}

From source file:com.travel.ac.view.UnderlinePageIndicator.java

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

    final Resources res = getResources();
    mTextPaint.setColor(Color.BLACK);
    mTextPaint.setStrokeWidth(5);
    mTextPaint.setTextSize(40);
    //Load defaults from resources
    final float defaultLineHeight = res.getInteger(R.integer.default_line_height);
    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);

    mTabLineHeight = a.getFloat(R.styleable.UnderlinePageIndicator_tab_line_height, defaultLineHeight);
    setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades));
    setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor));
    setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay));
    setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength));

    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.alex.view.loop.IndicatorView.java

public IndicatorView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    // ?/*from  w w  w  . j av  a 2  s  .  c o m*/
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.IndicatorView);
    normalBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_normalDrawable));
    selectBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_selectDrawable));
    mInterval = ta.getDimensionPixelOffset(R.styleable.IndicatorView_indicatorInterval, 6);
    normalColor = ta.getColor(R.styleable.IndicatorView_normalColor, Color.GRAY);
    selectColor = ta.getColor(R.styleable.IndicatorView_selectColor, Color.RED);
    mRadius = ta.getInteger(R.styleable.IndicatorView_indicatorRadius, 6);
    isCirculate = ta.getBoolean(R.styleable.IndicatorView_isCirculate, true);
    ta.recycle();
    // ?
    init();

}

From source file:com.todddavies.components.progressbar.ProgressWheel.java

/**
 * Parse the attributes passed to the view from the XML
 *
 * @param a the attributes to parse/*from www.j a  v  a  2 s. c  o m*/
 */
private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, barWidth);

    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, rimWidth);

    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis, delayMillis);
    if (delayMillis < 0) {
        delayMillis = 0;
    }

    barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor);

    barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength, barLength);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, textSize);

    textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor, textColor);

    //if the text is empty , so ignore it
    if (a.hasValue(R.styleable.ProgressWheel_text)) {
        setText(a.getString(R.styleable.ProgressWheel_text));
    }

    rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor, rimColor);

    circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor, circleColor);

    contourColor = a.getColor(R.styleable.ProgressWheel_contourColor, contourColor);
    contourSize = a.getDimension(R.styleable.ProgressWheel_contourSize, contourSize);

    // Recycle
    a.recycle();
}