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.mukesh.OtpView.java

public OtpView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final Resources res = getResources();
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.STROKE);
    animatorTextPaint.set(getPaint());//from w ww .ja  v  a  2 s .  c  o m
    final Resources.Theme theme = context.getTheme();
    TypedArray typedArray = theme.obtainStyledAttributes(attrs, R.styleable.OtpView, defStyleAttr, 0);
    viewType = typedArray.getInt(R.styleable.OtpView_viewType, VIEW_TYPE_RECTANGLE);
    otpViewItemCount = typedArray.getInt(R.styleable.OtpView_itemCount, DEFAULT_COUNT);
    otpViewItemHeight = (int) typedArray.getDimension(R.styleable.OtpView_itemHeight,
            res.getDimensionPixelSize(R.dimen.otp_view_item_size));
    otpViewItemWidth = (int) typedArray.getDimension(R.styleable.OtpView_itemWidth,
            res.getDimensionPixelSize(R.dimen.otp_view_item_size));
    otpViewItemSpacing = typedArray.getDimensionPixelSize(R.styleable.OtpView_itemSpacing,
            res.getDimensionPixelSize(R.dimen.otp_view_item_spacing));
    otpViewItemRadius = (int) typedArray.getDimension(R.styleable.OtpView_itemRadius, 0);
    lineWidth = (int) typedArray.getDimension(R.styleable.OtpView_lineWidth,
            res.getDimensionPixelSize(R.dimen.otp_view_item_line_width));
    lineColor = typedArray.getColorStateList(R.styleable.OtpView_lineColor);
    isCursorVisible = typedArray.getBoolean(R.styleable.OtpView_android_cursorVisible, true);
    cursorColor = typedArray.getColor(R.styleable.OtpView_cursorColor, getCurrentTextColor());
    cursorWidth = typedArray.getDimensionPixelSize(R.styleable.OtpView_cursorWidth,
            res.getDimensionPixelSize(R.dimen.otp_view_cursor_width));
    itemBackground = typedArray.getDrawable(R.styleable.OtpView_android_itemBackground);
    hideLineWhenFilled = typedArray.getBoolean(R.styleable.OtpView_hideLineWhenFilled, false);
    rtlTextDirection = typedArray.getBoolean(R.styleable.OtpView_rtlTextDirection, false);
    typedArray.recycle();
    if (lineColor != null) {
        cursorLineColor = lineColor.getDefaultColor();
    }
    updateCursorHeight();
    checkItemRadius();
    setMaxLength(otpViewItemCount);
    paint.setStrokeWidth(lineWidth);
    setupAnimator();
    super.setCursorVisible(false);
    setTextIsSelectable(false);
}

From source file:com.atobo.safecoo.view.coverflow.CoverFlowView.java

private void initAttributes(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCoverFlowView);

    int totalVisibleChildren = a.getInt(R.styleable.ImageCoverFlowView_visibleImage, 2);
    if (totalVisibleChildren % 2 == 0) {
        throw new IllegalArgumentException("visible image must be an odd number");
    }//from  ww w .jav a2  s  .com

    VISIBLE_VIEWS = totalVisibleChildren >> 1;

    reflectHeightFraction = a.getFraction(R.styleable.ImageCoverFlowView_reflectionHeight, 100, 0, 0.0f);
    if (reflectHeightFraction > 100) {
        reflectHeightFraction = 100;
    }
    reflectHeightFraction /= 100;
    reflectGap = a.getDimensionPixelSize(R.styleable.ImageCoverFlowView_reflectionGap, 0);

    mGravity = CoverFlowGravity.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowGravity,
            CoverFlowGravity.CENTER_VERTICAL.ordinal())];

    mLayoutMode = CoverFlowLayoutMode.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowLayoutMode,
            CoverFlowLayoutMode.WRAP_CONTENT.ordinal())];

    a.recycle();
}

From source file:cn.edu.zafu.easemob.imagecoverflow.CoverFlowView.java

private void initAttributes(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCoverFlowView);

    int totalVisibleChildren = a.getInt(R.styleable.ImageCoverFlowView_visibleImage, 3);
    setVisibleImage(totalVisibleChildren);

    reflectHeightFraction = a.getFraction(R.styleable.ImageCoverFlowView_reflectionHeight, 100, 0, 0.0f);
    if (reflectHeightFraction > 100) {
        reflectHeightFraction = 100;//from   w w w  .  j  a  v  a 2s  .c om
    }
    reflectHeightFraction /= 100;
    reflectGap = a.getDimensionPixelSize(R.styleable.ImageCoverFlowView_reflectionGap, 0);

    mGravity = CoverFlowGravity.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowGravity,
            CoverFlowGravity.CENTER_VERTICAL.ordinal())];

    mLayoutMode = CoverFlowLayoutMode.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowLayoutMode,
            CoverFlowLayoutMode.WRAP_CONTENT.ordinal())];

    a.recycle();
}

From source file:com.bridgelabz.appystore.librarycarosal.CoverFlowView.java

private void initAttributes(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCoverFlowView);

    int totalVisibleChildren = a.getInt(R.styleable.ImageCoverFlowView_visibleImage, 11);
    setVisibleImage(totalVisibleChildren);

    reflectHeightFraction = a.getFraction(R.styleable.ImageCoverFlowView_reflectionHeight, 100, 0, 0.0f);
    if (reflectHeightFraction > 100) {
        reflectHeightFraction = 100;//from w  w  w .  j  av  a 2 s  . com
    }
    reflectHeightFraction /= 100;
    reflectGap = a.getDimensionPixelSize(R.styleable.ImageCoverFlowView_reflectionGap, 0);

    mGravity = CoverFlowGravity.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowGravity,
            CoverFlowGravity.CENTER_VERTICAL.ordinal())];

    mLayoutMode = CoverFlowLayoutMode.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowLayoutMode,
            CoverFlowLayoutMode.WRAP_CONTENT.ordinal())];

    a.recycle();
}

From source file:com.gu.baselibrary.view.dragtoplayout.DragTopLayout.java

private void init(AttributeSet attrs) {
    dragHelper = ViewDragHelper.create(this, 1.0f, callback);
    // init from attrs
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DragTopLayout);
    //setCollapseOffset(a.getDimensionPixelSize(R.styleable.DragTopLayout_dtlCollapseOffset, collapseOffset));
    overDrag = a.getBoolean(R.styleable.DragTopLayout_dtlOverDrag, overDrag);
    dragContentViewId = a.getResourceId(R.styleable.DragTopLayout_dtlDragContentView, -1);
    topViewId = a.getResourceId(R.styleable.DragTopLayout_dtlTopView, -1);
    initOpen(a.getBoolean(R.styleable.DragTopLayout_dtlOpen, true));
    captureTop = a.getBoolean(R.styleable.DragTopLayout_dtlCaptureTop, false);
    topDistance = a.getInt(R.styleable.DragTopLayout_topDistance, 250);
    a.recycle();/*from   w ww  .  j  av a  2 s . c  o  m*/
}

From source file:com.facebook.LikeView.java

private void parseAttributes(AttributeSet attrs) {
    if (attrs == null || getContext() == null) {
        return;//from w w  w  .  j  av  a  2  s  .  co m
    }

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_like_view);
    if (a == null) {
        return;
    }

    objectId = Utility.coerceValueIfNullOrEmpty(
            a.getString(R.styleable.com_facebook_like_view_com_facebook_object_id), null);
    objectType = ObjectType.fromInt(a.getInt(R.styleable.com_facebook_like_view_com_facebook_object_type,
            ObjectType.DEFAULT.getValue()));
    likeViewStyle = Style
            .fromInt(a.getInt(R.styleable.com_facebook_like_view_com_facebook_style, Style.DEFAULT.getValue()));
    if (likeViewStyle == null) {
        throw new IllegalArgumentException("Unsupported value for LikeView 'style'");
    }

    auxiliaryViewPosition = AuxiliaryViewPosition
            .fromInt(a.getInt(R.styleable.com_facebook_like_view_com_facebook_auxiliary_view_position,
                    AuxiliaryViewPosition.DEFAULT.getValue()));
    if (auxiliaryViewPosition == null) {
        throw new IllegalArgumentException("Unsupported value for LikeView 'auxiliary_view_position'");
    }

    horizontalAlignment = HorizontalAlignment
            .fromInt(a.getInt(R.styleable.com_facebook_like_view_com_facebook_horizontal_alignment,
                    HorizontalAlignment.DEFAULT.getValue()));
    if (horizontalAlignment == null) {
        throw new IllegalArgumentException("Unsupported value for LikeView 'horizontal_alignment'");
    }

    foregroundColor = a.getColor(R.styleable.com_facebook_like_view_com_facebook_foreground_color,
            NO_FOREGROUND_COLOR);

    a.recycle();
}

From source file:android.support.designox.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.getColor(R.styleable.TextAppearance_android_textColor, mExpandedTextColor);
    }//from  w  ww. j  a v  a2s .com
    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:android.support.designox.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.getColor(R.styleable.TextAppearance_android_textColor, mCollapsedTextColor);
    }/*from  ww w  .ja  v a 2 s . c o m*/
    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.albedinsky.android.support.ui.widget.ScrollViewWidget.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.
 *//*from   w w  w.  j  av  a 2s . c om*/
@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_ScrollView_uiBackgroundTint)) {
        mTintInfo.backgroundTintList = typedArray
                .getColorStateList(R.styleable.Ui_Widget_ScrollView_uiBackgroundTint);
    }

    // Get tint modes.
    mTintInfo.backgroundTintMode = TintManager.parseTintMode(
            typedArray.getInt(R.styleable.Ui_Widget_ScrollView_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.antew.redditinpictures.library.widget.SwipeListView.java

private void initialize(AttributeSet attrs) {

    // If we are in an IDE Preview, don't initialize.
    if (isInEditMode()) {
        return;//  ww w.  j  a  v a 2 s . c  o m
    }

    if (attrs != null) {
        TypedArray styled = getContext().obtainStyledAttributes(attrs, R.styleable.SwipeListView);
        mFrontViewId = styled.getResourceId(R.styleable.SwipeListView_frontViewId, 0);
        mBackViewId = styled.getResourceId(R.styleable.SwipeListView_backViewId, 0);
        mCloseAllWhenScrolling = styled.getBoolean(R.styleable.SwipeListView_closeAllWhenScrolling, true);
        mOpenOnLongPress = styled.getBoolean(R.styleable.SwipeListView_openOnLongPress, true);
        setSwipeDirection(styled.getInt(R.styleable.SwipeListView_swipeDirection, SWIPE_DIRECTION_BOTH));
    }

    if (mFrontViewId == 0 || mBackViewId == 0) {
        throw new RuntimeException("You must specify a Front View and Back View");
    }

    ViewConfiguration viewConfig = ViewConfiguration.get(getContext());
    mTouchSlop = viewConfig.getScaledTouchSlop();
    mMinFlingVelocity = viewConfig.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = viewConfig.getScaledMaximumFlingVelocity();
    mAnimationTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

    super.setOnScrollListener(mInternalOnScrollListener);
    super.setOnItemLongClickListener(mInternalOnItemLongClickListener);
}