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:org.openintents.openpgp.util.OpenPgpKeyPreference.java

@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
    // This preference type's value type is Long, so we read the default
    // value from the attributes as an Integer.
    return (long) a.getInteger(index, NO_KEY);
}

From source file:org.dmfs.android.view.DrawablePagerTitleStrip.java

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

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    mGravity = a.getInteger(0, Gravity.BOTTOM);
    a.recycle();//from   w  ww . j  a v  a  2s  .  c  o  m

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

From source file:com.github.andrewlord1990.snackbarbuilder.toastbuilder.ToastBuilder.java

private void loadThemeAttributes() {
    TypedArray attrs = context.obtainStyledAttributes(null, R.styleable.ToastBuilderStyle,
            R.attr.toastBuilderStyle, 0);
    try {// w  ww.ja v  a 2s  .  c om
        messageTextColor = attrs.getColor(R.styleable.ToastBuilderStyle_toastBuilder_messageTextColor, 0);
        int durationAttr = attrs.getInteger(R.styleable.ToastBuilderStyle_toastBuilder_duration,
                Integer.MIN_VALUE);
        if (durationAttr > Integer.MIN_VALUE) {
            duration = durationAttr;
        }
    } finally {
        attrs.recycle();
    }
}

From source file:cc.solart.turbo.TurboRecyclerView.java

public TurboRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TurboRecyclerView);
    int max = ta.getInteger(R.styleable.TurboRecyclerView_maxDragDistance, DRAG_MAX_DISTANCE);
    mTotalDragDistance = convertDpToPixel(context, max);
    mLoadEnabled = ta.getBoolean(R.styleable.TurboRecyclerView_enableLoad, false);
    ta.recycle();// w  w  w  .  j a va2s .c  o m
}

From source file:com.gq.widget.loop.LoopViewPager.java

public LoopViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    init(context);/*  w w w. ja v a 2s. com*/
    TypedArray a = getResources().obtainAttributes(attrs, R.styleable.LoopViewPager);
    mIsAutoLoop = a.getBoolean(R.styleable.LoopViewPager_lvp_isAutoLoop, mIsAutoLoop);
    mDelayTime = a.getInteger(R.styleable.LoopViewPager_lvp_delayTime, mDelayTime);
    a.recycle();

    setAutoLoop(mIsAutoLoop, mDelayTime);
}

From source file:xiaofei.library.gridlayout.GridLayout.java

private void init(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GridLayoutAttrs);
    mHorizontalSpacing = (int) a.getDimension(R.styleable.GridLayoutAttrs_horizontalSpacing,
            mHorizontalSpacing);//www . j  a  v a2 s. c o m
    mVerticalSpacing = (int) a.getDimension(R.styleable.GridLayoutAttrs_verticalSpacing, mVerticalSpacing);
    mNumColumns = a.getInteger(R.styleable.GridLayoutAttrs_numColumns, mNumColumns);
    mNumRows = a.getInteger(R.styleable.GridLayoutAttrs_numRows, mNumRows);
    a.recycle();
}

From source file:org.smssecure.smssecure.preferences.ColorPreference.java

private void initAttrs(AttributeSet attrs, int defStyle) {
    TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ColorPreference, defStyle,
            defStyle);//from   w w  w. j  av a  2 s. c  o m

    try {
        mItemLayoutId = a.getResourceId(R.styleable.ColorPreference_itemLayout, mItemLayoutId);
        mNumColumns = a.getInteger(R.styleable.ColorPreference_numColumns, mNumColumns);
        //      int choicesResId = a.getResourceId(R.styleable.ColorPreference_choices,
        //                                         R.array.default_color_choice_values);
        //      if (choicesResId > 0) {
        //        String[] choices = a.getResources().getStringArray(choicesResId);
        //        mColorChoices = new int[choices.length];
        //        for (int i = 0; i < choices.length; i++) {
        //          mColorChoices[i] = Color.parseColor(choices[i]);
        //        }
        //      }

    } finally {
        a.recycle();
    }

    setWidgetLayoutResource(mItemLayoutId);
}

From source file:com.anl.wxb.jieqi.view.VerticalSeekBar.java

private void initialize(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR);

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VerticalSeekBar, defStyleAttr,
                defStyleRes);/*w  w  w.  j a va2s  .  c  o  m*/
        final int rotationAngle = a.getInteger(R.styleable.VerticalSeekBar_seekBarRotation, 0);
        if (isValidRotationAngle(rotationAngle)) {
            mRotationAngle = rotationAngle;
        }
        a.recycle();
    }
}

From source file:com.fast.access.kam.widget.colorpicker.dashclockpicker.ColorPreference.java

private void initAttrs(AttributeSet attrs, int defStyle) {
    TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ColorPreference, defStyle,
            defStyle);//from w w w .  j a v  a  2 s  . co m

    try {
        mItemLayoutId = a.getResourceId(R.styleable.ColorPreference_itemLayout, mItemLayoutId);
        mNumColumns = a.getInteger(R.styleable.ColorPreference_numColumns, mNumColumns);
        int choicesResId = a.getResourceId(R.styleable.ColorPreference_choices,
                R.array.default_color_choice_values);
        if (choicesResId > 0) {
            String[] choices = a.getResources().getStringArray(choicesResId);
            mColorChoices = new int[choices.length];
            for (int i = 0; i < choices.length; i++) {
                mColorChoices[i] = Color.parseColor(choices[i]);
            }
        }

    } finally {
        a.recycle();
    }

    setWidgetLayoutResource(mItemLayoutId);
}

From source file:com.github.pedrovgs.nox.NoxView.java

/**
 * Configures the Shape used to show the list of NoxItems.
 *///from w  w w  . ja  v  a 2  s. c o  m
private void initializeShapeConfig(TypedArray attributes) {
    defaultShapeKey = attributes.getInteger(R.styleable.nox_shape, ShapeFactory.FIXED_CIRCULAR_SHAPE_KEY);
}