@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); }
public LayoutParams(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); gravity = a.getInteger(0, Gravity.TOP); a.recycle(); } }
public LayoutParams(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); gravity = a.getInteger(0, Gravity.TOP); a.recycle(); } }
public LayoutParams(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); gravity = a.getInteger(0, Gravity.TOP); a.recycle(); } }
@Keep public StaggeredDistanceSlide(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StaggeredDistanceSlide); spread = a.getInteger(R.styleable.StaggeredDistanceSlide_spread, spread); a.recycle(); }
public ENRefreshView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.refresh); int color = ta.getColor(R.styleable.refresh_refresh_line_color, DEFAULT_LINE_COLOR); int width = ta.getInteger(R.styleable.refresh_refresh_line_width, DEFAULT_LINE_WIDTH); ta.recycle(); mDuration = DEFAULT_DURATION; mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setColor(color); mPaint.setStrokeWidth(width); }
private void init(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SimpleGridLayout); mColumnCount = a.getInteger(R.styleable.SimpleGridLayout_columnCount, DEFAULT_COLUMN_COUNT); mItemMargin = a.getDimensionPixelOffset(R.styleable.SimpleGridLayout_itemMargin, 0); a.recycle(); }
public IcsLinearLayout(Context context, int themeAttr) { super(context); TypedArray a = context.obtainStyledAttributes(null, LL, themeAttr, 0); setDividerDrawable(a.getDrawable(IcsLinearLayout.LL_DIVIDER)); mDividerPadding = a.getDimensionPixelSize(LL_DIVIDER_PADDING, 0); mShowDividers = a.getInteger(LL_SHOW_DIVIDER, SHOW_DIVIDER_NONE); a.recycle(); }
public NameCard(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NameCard); try { mAge = a.getInteger(R.styleable.NameCard_age, 0); } finally { a.recycle(); } init(); }
protected void initAttrs(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.superrecyclerview); try { mClipToPadding = a.getBoolean(R.styleable.superrecyclerview_recyclerClipToPadding, false); mPadding = (int) a.getDimension(R.styleable.superrecyclerview_recyclerPadding, -1.0f); mPaddingTop = (int) a.getDimension(R.styleable.superrecyclerview_recyclerPaddingTop, 0.0f); mPaddingBottom = (int) a.getDimension(R.styleable.superrecyclerview_recyclerPaddingBottom, 0.0f); mPaddingLeft = (int) a.getDimension(R.styleable.superrecyclerview_recyclerPaddingLeft, 0.0f); mPaddingRight = (int) a.getDimension(R.styleable.superrecyclerview_recyclerPaddingRight, 0.0f); mScrollbarStyle = a.getInteger(R.styleable.superrecyclerview_scrollbarStyle, -1); mScrollbar = a.getInteger(R.styleable.superrecyclerview_scrollbars, -1); mEmptyId = a.getResourceId(R.styleable.superrecyclerview_layout_empty, 0); mProgressId = a.getResourceId(R.styleable.superrecyclerview_layout_progress, 0); mErrorId = a.getResourceId(R.styleable.superrecyclerview_layout_error, R.layout.common_net_error_view); } finally { a.recycle(); } }
@Override public int getOriginalHeight() { return attributeArray().getInteger(R.styleable.FillableLoader_fl_originalHeight, -1); }
protected void initAttr(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PathView); mDuration = typedArray.getInteger(R.styleable.PathView_duration, mDuration); showPainter = typedArray.getBoolean(R.styleable.PathView_showPainter, showPainter); showPainterActually = typedArray.getBoolean(R.styleable.PathView_showPainterActually, showPainterActually); mPathStrokeWidth = typedArray.getDimensionPixelOffset(R.styleable.PathView_pathStrokeWidth, mPathStrokeWidth); mTextStrokeColor = typedArray.getColor(R.styleable.PathView_pathStrokeColor, mTextStrokeColor); mPaintStrokeWidth = typedArray.getDimensionPixelOffset(R.styleable.PathView_paintStrokeWidth, mPaintStrokeWidth); mPaintStrokeColor = typedArray.getColor(R.styleable.PathView_paintStrokeColor, mPaintStrokeColor); mRepeatStyle = typedArray.getInt(R.styleable.PathView_repeat, mRepeatStyle); typedArray.recycle(); }
public int getFillPercentage() { return attributeArray().getInteger(R.styleable.FillableLoader_fl_fillPercentage, context().getResources().getInteger(R.integer.fillPercentage)); } @Override public ClippingTransform getClippingTransform() {
@Override public int getStrokeDrawingDuration() { return attributeArray().getInteger(R.styleable.FillableLoader_fl_strokeDrawingDuration, context().getResources().getInteger(R.integer.strokeDrawingDuration)); }
@Override public int getFillDuration() { return attributeArray().getInteger(R.styleable.FillableLoader_fl_fillDuration, context().getResources().getInteger(R.integer.fillDuration)); }
private void init(AttributeSet attrs) { if (attrs == null) { mEmojiconSize = getLineHeight(); } else { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon); mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getLineHeight()); mTextStart = a.getInteger(R.styleable.Emojicon_emojiconTextStart, 0); mTextLength = a.getInteger(R.styleable.Emojicon_emojiconTextLength, -1); a.recycle(); } setText(getText()); }
private void init(AttributeSet attrs) { mEmojiconTextSize = (int) getTextSize(); if (attrs == null) { mEmojiconSize = (int) getTextSize(); } else { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon); mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize()); mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE); mTextStart = a.getInteger(R.styleable.Emojicon_emojiconTextStart, 0); mTextLength = a.getInteger(R.styleable.Emojicon_emojiconTextLength, -1); mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false); a.recycle(); } setText(getText()); }
@Override public ClippingTransform getClippingTransform() { int value = attributeArray().getInteger(R.styleable.FillableLoader_fl_clippingTransform, 0); return transformFactory.getClippingTransformFor(value); }
@OnLoadStyle static void onLoadStyle( ComponentContext c, Output<Drawable> drawable, Output<ScaleType> scaleType) { final TypedArray a = c.obtainStyledAttributes(R.styleable.Image, 0); for (int i = 0, size = a.getIndexCount(); i < size; i++) { final int attr = a.getIndex(i); if (attr == R.styleable.Image_android_src) { drawable.set(c.getAndroidContext().getResources().getDrawable(a.getResourceId(attr, 0))); } else if (attr == R.styleable.Image_android_scaleType) { scaleType.set(SCALE_TYPE[a.getInteger(attr, -1)]); } } a.recycle(); }
@Test public void getInteger_shouldReturnDefaultValue() throws Exception { assertThat(context.obtainStyledAttributes(new int[]{android.R.attr.alpha}).getInteger(0, -1)).isEqualTo(-1); }