@SuppressWarnings("ResourceType") private static @RepeatModeUtil.RepeatToggleModes int getRepeatToggleModes( TypedArray a, @RepeatModeUtil.RepeatToggleModes int repeatToggleModes) { return a.getInt(R.styleable.PlayerControlView_repeat_toggle_modes, repeatToggleModes); }
public ReflowText(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ReflowText); velocity = a.getDimensionPixelSize(R.styleable.ReflowText_velocity, velocity); minDuration = a.getInt(R.styleable.ReflowText_minDuration, (int) minDuration); maxDuration = a.getInt(R.styleable.ReflowText_maxDuration, (int) maxDuration); staggerDelay = a.getInt(R.styleable.ReflowText_staggerDelay, (int) staggerDelay); freezeFrame = a.getBoolean(R.styleable.ReflowText_freezeFrame, false); a.recycle(); }
public TwoLevelHeader(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mSpinnerStyle = SpinnerStyle.FixedBehind; TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TwoLevelHeader); mMaxRage = ta.getFloat(R.styleable.TwoLevelHeader_srlMaxRage, mMaxRage); mFloorRage = ta.getFloat(R.styleable.TwoLevelHeader_srlFloorRage, mFloorRage); mRefreshRage = ta.getFloat(R.styleable.TwoLevelHeader_srlRefreshRage, mRefreshRage); mFloorDuration = ta.getInt(R.styleable.TwoLevelHeader_srlFloorDuration, mFloorDuration); mEnableTwoLevel = ta.getBoolean(R.styleable.TwoLevelHeader_srlEnableTwoLevel, mEnableTwoLevel); mEnablePullToCloseTwoLevel = ta.getBoolean(R.styleable.TwoLevelHeader_srlEnablePullToCloseTwoLevel, mEnablePullToCloseTwoLevel); ta.recycle(); }
TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.IconView, 0, 0); // Gets you the 'value' number - 0 or 666 in your example if (a.hasValue(R.styleable.IconView_icon)) { int value = a.getInt(R.styleable.IconView_icon, 0)); } a.recycle(); }
GifViewAttributes(final View view, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { final TypedArray gifViewAttributes = view.getContext().obtainStyledAttributes(attrs, R.styleable.GifView, defStyleAttr, defStyleRes); freezesAnimation = gifViewAttributes.getBoolean(R.styleable.GifView_freezesAnimation, false); mLoopCount = gifViewAttributes.getInt(R.styleable.GifView_loopCount, -1); gifViewAttributes.recycle(); }
public FunGameHitBlockHeader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FunGameHitBlockHeader); speed = ta.getInt(R.styleable.FunGameHitBlockHeader_fghBallSpeed, DensityUtil.dp2px(SPEED)); blockHorizontalNum = ta.getInt(R.styleable.FunGameHitBlockHeader_fghBlockHorizontalNum, BLOCK_HORIZONTAL_NUM); ta.recycle(); blockPaint = new Paint(Paint.ANTI_ALIAS_FLAG); blockPaint.setStyle(Paint.Style.FILL); BALL_RADIUS = DensityUtil.dp2px(4); }
public AspectRatioFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); resizeMode = RESIZE_MODE_FIT; if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AspectRatioFrameLayout, 0, 0); try { resizeMode = a.getInt(R.styleable.AspectRatioFrameLayout_resize_mode, RESIZE_MODE_FIT); } finally { a.recycle(); } } aspectRatioUpdateDispatcher = new AspectRatioUpdateDispatcher(); }
public LayoutParams(Context context, AttributeSet attrs) { super(context, attrs); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SmartRefreshLayout_Layout); backgroundColor = ta.getColor(R.styleable.SmartRefreshLayout_Layout_layout_srlBackgroundColor, backgroundColor); if (ta.hasValue(R.styleable.SmartRefreshLayout_Layout_layout_srlSpinnerStyle)) { spinnerStyle = SpinnerStyle.values()[ta.getInt(R.styleable.SmartRefreshLayout_Layout_layout_srlSpinnerStyle, SpinnerStyle.Translate.ordinal())]; } ta.recycle(); }
static int getAttrInt(Context context, AttributeSet attrs, int attr, int defaultValue) { TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr}); final int value = a.getInt(0, defaultValue); a.recycle(); return value; }
protected void initialise(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapProgressBarGroup); try { this.maxProgress = a.getInt(R.styleable.BootstrapProgressBarGroup_bootstrapMaxProgress, 100); this.sizeOrdinal = a.getInt(R.styleable.BootstrapProgressBarGroup_bootstrapSize, 2); this.rounded = a.getBoolean(R.styleable.BootstrapProgressBarGroup_roundedCorners, false); } finally { a.recycle(); } setOrientation(HORIZONTAL); updateBootstrapGroup(); }
static PorterDuff.Mode getTintMode(Context context, AttributeSet attrs, int tintModeAttr) { TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{tintModeAttr}); final int tintModeValue = a.getInt(0, 0); a.recycle(); return parseTintMode(tintModeValue, PorterDuff.Mode.SRC_IN); }
private void parseAttributes(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes( attrs, R.styleable.com_facebook_profile_picture_view); setPresetSize(a.getInt(R.styleable.com_facebook_profile_picture_view_com_facebook_preset_size, CUSTOM)); isCropped = a.getBoolean( R.styleable.com_facebook_profile_picture_view_com_facebook_is_cropped, IS_CROPPED_DEFAULT_VALUE); a.recycle(); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public SpinKitView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SpinKitView, defStyleAttr, defStyleRes); mStyle = Style.values()[a.getInt(R.styleable.SpinKitView_SpinKit_Style, 0)]; mColor = a.getColor(R.styleable.SpinKitView_SpinKit_Color, Color.WHITE); a.recycle(); init(); setIndeterminate(true); }
private void initialise(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapLabel); try { int attrValue = a.getInt(R.styleable.BootstrapLabel_bootstrapHeading, 5); this.roundable = a.getBoolean(R.styleable.BootstrapLabel_roundedCorners, false); this.bootstrapHeading = DefaultBootstrapHeading.fromAttributeValue(attrValue); } finally { a.recycle(); } updateBootstrapState(); }
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.picker_place_picker_fragment); setRadiusInMeters(a.getInt(R.styleable.picker_place_picker_fragment_radius_in_meters, radiusInMeters)); setResultsLimit(a.getInt(R.styleable.picker_place_picker_fragment_results_limit, resultsLimit)); if (a.hasValue(R.styleable.picker_place_picker_fragment_results_limit)) { setSearchText(a.getString(R.styleable.picker_place_picker_fragment_search_text)); } showSearchBox = a.getBoolean(R.styleable.picker_place_picker_fragment_show_search_box, showSearchBox); a.recycle(); }
public int resolveIntAttr(@AttrRes int attrResId, @IntegerRes int defResId) { mAttrs[0] = attrResId; TypedArray a = mTheme.obtainStyledAttributes(mAttrs); try { return a.getInt(0, resolveIntRes(defResId)); } finally { a.recycle(); } }
private void initialise(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BootstrapButton); try { int sizeOrdinal = a.getInt(R.styleable.BootstrapButton_bootstrapSize, -1); bootstrapSize = DefaultBootstrapSize.fromAttributeValue(sizeOrdinal).scaleFactor(); } finally { a.recycle(); } updateBootstrapState(); }
@Test public void getInt_shouldReturnDefaultValue() throws Exception { assertThat(context.obtainStyledAttributes(new int[]{android.R.attr.alpha}).getInt(0, -1)).isEqualTo(-1); }
@Test public void obtainAttributes_shouldReturnValuesFromResources() throws Exception { XmlPullParser parser = resources.getXml(R.xml.xml_attrs); parser.next(); parser.next(); AttributeSet attributes = Xml.asAttributeSet(parser); TypedArray typedArray = resources .obtainAttributes(attributes, new int[]{android.R.attr.title, android.R.attr.scrollbarFadeDuration}); assertThat(typedArray.getString(0)).isEqualTo("Android Title"); assertThat(typedArray.getInt(1, 0)).isEqualTo(1111); typedArray.recycle(); }
@Test public void getInt_withFlags_shouldReturnValue() throws Exception { TypedArray typedArray = context.obtainStyledAttributes( Robolectric.buildAttributeSet() .addAttribute(android.R.attr.gravity, "top|left") .build(), new int[]{android.R.attr.gravity}); assertThat(typedArray.getInt(0, -1)).isEqualTo(0x33); }