Example usage for android.content.res TypedArray getInt

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

Introduction

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

Prototype

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

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:com.commonsware.cwac.crossport.design.widget.FloatingActionButton.java

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

    // ThemeUtils.checkAppCompatTheme(context);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr,
            R.style.Widget_Design_FloatingActionButton);
    mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_android_backgroundTint);
    mBackgroundTintMode = ViewUtils//w ww.  j  a v a  2 s . c  o  m
            .parseTintMode(a.getInt(R.styleable.FloatingActionButton_android_backgroundTintMode, -1), null);
    mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
    mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO);
    mCustomSize = a.getDimensionPixelSize(R.styleable.FloatingActionButton_fabCustomSize, 0);
    mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
    final float elevation = a.getDimension(R.styleable.FloatingActionButton_android_elevation, 0f);
    final float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f);
    mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
    a.recycle();

    /*
        mImageHelper = new AppCompatImageHelper(this);
        mImageHelper.loadFromAttributes(attrs, defStyleAttr);
    */

    mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size);

    getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth);
    getImpl().setElevation(elevation);
    getImpl().setPressedTranslationZ(pressedTranslationZ);
}

From source file:com.layer.messenger.makemoji.MakeMojiAtlasComposer.java

private void parseStyle(Context context, AttributeSet attrs, int defStyle) {
    TypedArray ta = context.getTheme().obtainStyledAttributes(attrs,
            com.layer.atlas.R.styleable.AtlasMessageComposer, com.layer.atlas.R.attr.AtlasMessageComposer,
            defStyle);/*  w ww .j a va2  s  .  c  o  m*/
    mEnabled = ta.getBoolean(com.layer.atlas.R.styleable.AtlasMessageComposer_android_enabled, true);
    this.mTextColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextColor,
            context.getResources().getColor(com.layer.atlas.R.color.atlas_text_black));
    this.mTextSize = ta.getDimensionPixelSize(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextSize,
            context.getResources().getDimensionPixelSize(com.layer.atlas.R.dimen.atlas_text_size_input));
    this.mTextStyle = ta.getInt(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextStyle,
            Typeface.NORMAL);
    String typeFaceName = ta.getString(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextTypeface);
    this.mTypeFace = typeFaceName != null ? Typeface.create(typeFaceName, mTextStyle) : null;
    this.mUnderlineColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputUnderlineColor,
            context.getResources().getColor(com.layer.atlas.R.color.atlas_color_primary_blue));
    this.mCursorColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputCursorColor,
            context.getResources().getColor(com.layer.atlas.R.color.atlas_color_primary_blue));
    this.mAttachmentSendersBackground = ta
            .getDrawable(com.layer.atlas.R.styleable.AtlasMessageComposer_attachmentSendersBackground);
    ta.recycle();
}

From source file:com.devbrackets.android.recyclerext.widget.FastScroll.java

/**
 * Retrieves the xml attributes associated with the popup bubble.
 * This includes the drawable, tint color, alignment, font options, etc.
 *
 * @param typedArray The array of attributes to use
 *//*from  w  ww  . j a  v  a  2s  .  co m*/
protected void retrieveBubbleAttributes(@NonNull TypedArray typedArray) {
    showBubble = typedArray.getBoolean(R.styleable.FastScroll_re_show_bubble, true);
    bubbleAlignment = BubbleAlignment.get(typedArray.getInt(R.styleable.FastScroll_re_bubble_alignment, 3));

    int textColor = getColor(R.color.recyclerext_fast_scroll_bubble_text_color_default);
    textColor = typedArray.getColor(R.styleable.FastScroll_re_bubble_text_color, textColor);

    int textSize = getResources()
            .getDimensionPixelSize(R.dimen.recyclerext_fast_scroll_bubble_text_size_default);
    textSize = typedArray.getDimensionPixelSize(R.styleable.FastScroll_re_bubble_text_size, textSize);

    Drawable backgroundDrawable = getDrawable(typedArray, R.styleable.FastScroll_re_bubble_background);
    int backgroundColor = getColor(R.color.recyclerext_fast_scroll_bubble_color_default);
    backgroundColor = typedArray.getColor(R.styleable.FastScroll_re_bubble_color, backgroundColor);

    if (backgroundDrawable == null) {
        backgroundDrawable = tint(getDrawable(R.drawable.recyclerext_fast_scroll_bubble), backgroundColor);
    }

    bubble.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    bubble.setTextColor(textColor);
    bubble.setBackground(backgroundDrawable);
}

From source file:com.albedinsky.android.support.ui.widget.HorizontalScrollViewWidget.java

/**
 * Called from the constructor to process tint values for this view. <b>Note</b>, that for
 * {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} is this call ignored.
 *
 * @param context    The context passed to constructor.
 * @param typedArray TypedArray obtained for styleable attributes specific for this view.
 *//*  w  w  w  .  j  a v a  2 s  .  co  m*/
@SuppressWarnings("All")
private void processTintValues(Context context, TypedArray typedArray) {
    // Do not handle for LOLLIPOP.
    if (UiConfig.LOLLIPOP) {
        return;
    }

    this.ensureTintInfo();

    // Get tint colors.
    if (typedArray.hasValue(R.styleable.Ui_Widget_HorizontalScrollView_uiBackgroundTint)) {
        mTintInfo.backgroundTintList = typedArray
                .getColorStateList(R.styleable.Ui_Widget_HorizontalScrollView_uiBackgroundTint);
    }

    // Get tint modes.
    mTintInfo.backgroundTintMode = TintManager.parseTintMode(
            typedArray.getInt(R.styleable.Ui_Widget_HorizontalScrollView_uiBackgroundTintMode, 0),
            mTintInfo.backgroundTintList != null ? PorterDuff.Mode.SRC_IN : null);

    // If there is no tint mode specified within style/xml do not tint at all.
    if (mTintInfo.backgroundTintMode == null) {
        mTintInfo.backgroundTintList = null;
    }

    mTintInfo.hasBackgroundTintList = mTintInfo.backgroundTintList != null;
    mTintInfo.hasBackgroundTinMode = mTintInfo.backgroundTintMode != null;
}

From source file:com.commonsware.cwac.crossport.design.widget.CollapsingTextHelper.java

void setExpandedTextAppearance(int resId) {
    TypedArray a = mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
        mExpandedTextColor = a.getColorStateList(R.styleable.TextAppearance_android_textColor);
    }/*from w  ww  .j  av  a 2 s. c  o  m*/
    if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
        mExpandedTextSize = a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize,
                (int) mExpandedTextSize);
    }
    mExpandedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
    mExpandedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
    mExpandedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
    mExpandedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
    a.recycle();

    if (Build.VERSION.SDK_INT >= 16) {
        mExpandedTypeface = readFontFamilyTypeface(resId);
    }

    recalculate();
}

From source file:com.commonsware.cwac.crossport.design.widget.CollapsingTextHelper.java

void setCollapsedTextAppearance(int resId) {
    TypedArray a = mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
        mCollapsedTextColor = a.getColorStateList(R.styleable.TextAppearance_android_textColor);
    }//from w  ww  .  jav  a  2 s.com
    if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
        mCollapsedTextSize = a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize,
                (int) mCollapsedTextSize);
    }
    mCollapsedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
    mCollapsedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
    mCollapsedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
    mCollapsedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
    a.recycle();

    if (Build.VERSION.SDK_INT >= 16) {
        mCollapsedTypeface = readFontFamilyTypeface(resId);
    }

    recalculate();
}

From source file:com.appunite.list.FastScroller.java

private void init(Context context) {
    // Get both the scrollbar states drawables
    TypedArray ta = context.getTheme().obtainStyledAttributes(ATTRS);
    useThumbDrawable(context, ta.getDrawable(THUMB_DRAWABLE));
    mTrackDrawable = ta.getDrawable(TRACK_DRAWABLE);

    mOverlayDrawableLeft = ta.getDrawable(PREVIEW_BACKGROUND_LEFT);
    mOverlayDrawableRight = ta.getDrawable(PREVIEW_BACKGROUND_RIGHT);
    mOverlayPosition = ta.getInt(OVERLAY_POSITION, OVERLAY_FLOATING);

    mScrollCompleted = true;/*from www .  jav a 2 s .c o  m*/

    getSectionsFromIndexer();

    mOverlaySize = context.getResources().getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
    mOverlayPos = new RectF();
    mScrollFade = new ScrollFade();
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setTextSize(mOverlaySize / 2);

    ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
    int textColorNormal = textColor.getDefaultColor();
    mPaint.setColor(textColorNormal);
    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);

    // to show mOverlayDrawable properly
    if (mList.getWidth() > 0 && mList.getHeight() > 0) {
        onSizeChanged(mList.getWidth(), mList.getHeight(), 0, 0);
    }

    mState = STATE_NONE;
    refreshDrawableState();

    ta.recycle();

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

    mMatchDragPosition = context
            .getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB;

    setScrollbarPosition(Compat.getVerticalScrollbarPosition(mList));
}

From source file:com.common.widget.hzlib.FastScroller.java

private void init(Context context) {
    // Get both the scrollbar states drawables
    TypedArray ta = context.getTheme().obtainStyledAttributes(ATTRS);
    useThumbDrawable(context, ta.getDrawable(THUMB_DRAWABLE));
    mTrackDrawable = ta.getDrawable(TRACK_DRAWABLE);

    mOverlayDrawableLeft = ta.getDrawable(PREVIEW_BACKGROUND_LEFT);
    mOverlayDrawableRight = ta.getDrawable(PREVIEW_BACKGROUND_RIGHT);
    mOverlayPosition = ta.getInt(OVERLAY_POSITION, OVERLAY_FLOATING);

    mScrollCompleted = true;//from w  ww. j a va 2 s .c  om

    getSectionsFromIndexer();

    mOverlaySize = context.getResources().getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
    mOverlayPos = new RectF();
    mScrollFade = new ScrollFade();
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setTextSize(mOverlaySize / 2);

    ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
    int textColorNormal = textColor.getDefaultColor();
    mPaint.setColor(textColorNormal);
    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);

    // to show mOverlayDrawable properly
    if (mList.getWidth() > 0 && mList.getHeight() > 0) {
        onSizeChanged(mList.getWidth(), mList.getHeight(), 0, 0);
    }

    mState = STATE_NONE;
    refreshDrawableState();

    ta.recycle();

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

    mMatchDragPosition = context
            .getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB;

    setScrollbarPosition(mList.getVerticalScrollbarPosition());
}

From source file:com.nick.documents.widget.FlexibleImageView.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FlexibleImageView, defStyleAttr, 0);

    final float density = getContext().getResources().getDisplayMetrics().density;

    mBgColor = a.getColor(R.styleable.FlexibleImageView_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mInnerRadius = a.getDimensionPixelOffset(R.styleable.FlexibleImageView_inner_radius, -1);

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.FlexibleImageView_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mTextSize = a.getDimensionPixelOffset(R.styleable.FlexibleImageView_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.FlexibleImageView_progress_text_color, Color.BLACK);

    mCircleBackgroundEnabled = a.getBoolean(R.styleable.FlexibleImageView_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.FlexibleImageView_progress, 0);
    mMax = a.getInt(R.styleable.FlexibleImageView_max_flip, 100);
    int textVisible = a.getInt(R.styleable.FlexibleImageView_progress_text_visibility, 1);
    if (textVisible != 1) {
        mHasText = true;//from   w  w  w  .ja v  a2 s  .com
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    mRingColors = context.getResources().getIntArray(R.array.ring_colors);
    super.setImageDrawable(mProgressDrawable);
    mHandler = new Handler();
}

From source file:com.king.view.superswiperefreshlayout.SuperSwipeRefreshLayout.java

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

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

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

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
    final TypedArray a2 = context.obtainStyledAttributes(attrs, R.styleable.SuperSwipeRefreshLayout);
    Direction direction = Direction.getFromInt(a2.getInt(R.styleable.SuperSwipeRefreshLayout_direction, 0));
    if (direction != Direction.BOTH) {
        mDirection = direction;
        mBothDirection = false;
    } else {
        mDirection = Direction.TOP;
        mBothDirection = true;
    }
    a2.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}