Java Code Examples for androidx.appcompat.widget.TintTypedArray#recycle()
The following examples show how to use
androidx.appcompat.widget.TintTypedArray#recycle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollapsingTextHelper.java From UIWidget with Apache License 2.0 | 6 votes |
public void setCollapsedTextAppearance(int resId) { TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), resId, R.styleable.CollapsingTextAppearance); if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textColor)) { mCollapsedTextColor = a.getColorStateList(R.styleable.CollapsingTextAppearance_android_textColor); } if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textSize)) { mCollapsedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, (int) mCollapsedTextSize); } mCollapsedShadowColor = a.getInt(R.styleable.CollapsingTextAppearance_android_shadowColor, 0); mCollapsedShadowDx = a.getFloat(R.styleable.CollapsingTextAppearance_android_shadowDx, 0); mCollapsedShadowDy = a.getFloat(R.styleable.CollapsingTextAppearance_android_shadowDy, 0); mCollapsedShadowRadius = a.getFloat(R.styleable.CollapsingTextAppearance_android_shadowRadius, 0); a.recycle(); if (Build.VERSION.SDK_INT >= 16) { mCollapsedTypeface = readFontFamilyTypeface(resId); } recalculate(); }
Example 2
Source File: CollapsingTextHelper.java From UIWidget with Apache License 2.0 | 6 votes |
/** * 设置最大化状态Text样式id * * @param resId */ public void setExpandedTextAppearance(int resId) { TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), resId, R.styleable.CollapsingTextAppearance); if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textColor)) { mExpandedTextColor = a.getColorStateList(R.styleable.CollapsingTextAppearance_android_textColor); } if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textSize)) { mExpandedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, (int) mExpandedTextSize); } mExpandedShadowColor = a.getInt( R.styleable.CollapsingTextAppearance_android_shadowColor, 0); mExpandedShadowDx = a.getFloat( R.styleable.CollapsingTextAppearance_android_shadowDx, 0); mExpandedShadowDy = a.getFloat( R.styleable.CollapsingTextAppearance_android_shadowDy, 0); mExpandedShadowRadius = a.getFloat( R.styleable.CollapsingTextAppearance_android_shadowRadius, 0); a.recycle(); if (Build.VERSION.SDK_INT >= 16) { mExpandedTypeface = readFontFamilyTypeface(resId); } recalculate(); }
Example 3
Source File: DrawableHelper.java From GetApk with MIT License | 5 votes |
public static int getThemeAttrColor(Context context, int attr) { TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, null, new int[]{attr}); try { return a.getColor(0, 0); } finally { a.recycle(); } }
Example 4
Source File: TurbolinksToolbar.java From react-native-turbolinks with MIT License | 5 votes |
@SuppressLint("RestrictedApi") private int getThemeAttrColor(Context context, int attr) { TEMP_ARRAY[0] = attr; TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, null, TEMP_ARRAY); try { return a.getColor(0, 0); } finally { a.recycle(); } }
Example 5
Source File: BottomNavigationViewInner.java From smart-farmer-android with Apache License 2.0 | 5 votes |
public BottomNavigationViewInner(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TintTypedArray a = ThemeEnforcement.obtainTintedStyledAttributes(context, attrs, R.styleable.BottomNavigationView, defStyleAttr, R.style.Widget_Design_BottomNavigationView, new int[]{R.styleable.BottomNavigationView_itemTextAppearanceInactive, R.styleable.BottomNavigationView_itemTextAppearanceActive}); // clear if you don't have set item icon tint list if (!a.hasValue(R.styleable.BottomNavigationView_itemIconTint)) { clearIconTintColor(); } a.recycle(); }
Example 6
Source File: TabItem.java From material-components-android with Apache License 2.0 | 5 votes |
public TabItem(Context context, AttributeSet attrs) { super(context, attrs); final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.TabItem); text = a.getText(R.styleable.TabItem_android_text); icon = a.getDrawable(R.styleable.TabItem_android_icon); customLayout = a.getResourceId(R.styleable.TabItem_android_layout, 0); a.recycle(); }
Example 7
Source File: MaterialProgressBar.java From MaterialProgressBar with Apache License 2.0 | 4 votes |
@SuppressWarnings("RestrictedApi") private void init(@Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { Context context = getContext(); TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.MaterialProgressBar, defStyleAttr, defStyleRes); mProgressStyle = a.getInt(R.styleable.MaterialProgressBar_mpb_progressStyle, PROGRESS_STYLE_CIRCULAR); boolean setBothDrawables = a.getBoolean( R.styleable.MaterialProgressBar_mpb_setBothDrawables, false); boolean useIntrinsicPadding = a.getBoolean( R.styleable.MaterialProgressBar_mpb_useIntrinsicPadding, true); boolean showProgressBackground = a.getBoolean( R.styleable.MaterialProgressBar_mpb_showProgressBackground, mProgressStyle == PROGRESS_STYLE_HORIZONTAL); int determinateCircularProgressStyle = a.getInt( R.styleable.MaterialProgressBar_mpb_determinateCircularProgressStyle, DETERMINATE_CIRCULAR_PROGRESS_STYLE_NORMAL); if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressTint)) { mProgressTintInfo.mProgressTint = a.getColorStateList( R.styleable.MaterialProgressBar_mpb_progressTint); mProgressTintInfo.mHasProgressTint = true; } if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressTintMode)) { mProgressTintInfo.mProgressTintMode = DrawableCompat.parseTintMode(a.getInt( R.styleable.MaterialProgressBar_mpb_progressTintMode, -1), null); mProgressTintInfo.mHasProgressTintMode = true; } if (a.hasValue(R.styleable.MaterialProgressBar_mpb_secondaryProgressTint)) { mProgressTintInfo.mSecondaryProgressTint = a.getColorStateList( R.styleable.MaterialProgressBar_mpb_secondaryProgressTint); mProgressTintInfo.mHasSecondaryProgressTint = true; } if (a.hasValue(R.styleable.MaterialProgressBar_mpb_secondaryProgressTintMode)) { mProgressTintInfo.mSecondaryProgressTintMode = DrawableCompat.parseTintMode(a.getInt( R.styleable.MaterialProgressBar_mpb_secondaryProgressTintMode, -1), null); mProgressTintInfo.mHasSecondaryProgressTintMode = true; } if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressBackgroundTint)) { mProgressTintInfo.mProgressBackgroundTint = a.getColorStateList( R.styleable.MaterialProgressBar_mpb_progressBackgroundTint); mProgressTintInfo.mHasProgressBackgroundTint = true; } if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressBackgroundTintMode)) { mProgressTintInfo.mProgressBackgroundTintMode = DrawableCompat.parseTintMode(a.getInt( R.styleable.MaterialProgressBar_mpb_progressBackgroundTintMode, -1), null); mProgressTintInfo.mHasProgressBackgroundTintMode = true; } if (a.hasValue(R.styleable.MaterialProgressBar_mpb_indeterminateTint)) { mProgressTintInfo.mIndeterminateTint = a.getColorStateList( R.styleable.MaterialProgressBar_mpb_indeterminateTint); mProgressTintInfo.mHasIndeterminateTint = true; } if (a.hasValue(R.styleable.MaterialProgressBar_mpb_indeterminateTintMode)) { mProgressTintInfo.mIndeterminateTintMode = DrawableCompat.parseTintMode(a.getInt( R.styleable.MaterialProgressBar_mpb_indeterminateTintMode, -1), null); mProgressTintInfo.mHasIndeterminateTintMode = true; } a.recycle(); switch (mProgressStyle) { case PROGRESS_STYLE_CIRCULAR: if (isIndeterminate() || setBothDrawables) { if (!isInEditMode()) { setIndeterminateDrawable( new AnimationScaleIndeterminateCircularProgressDrawable(context)); } } if (!isIndeterminate() || setBothDrawables) { setProgressDrawable(new CircularProgressDrawable( determinateCircularProgressStyle, context)); } break; case PROGRESS_STYLE_HORIZONTAL: if (isIndeterminate() || setBothDrawables) { if (!isInEditMode()) { setIndeterminateDrawable(new IndeterminateHorizontalProgressDrawable( context)); } } if (!isIndeterminate() || setBothDrawables) { setProgressDrawable(new HorizontalProgressDrawable(context)); } break; default: throw new IllegalArgumentException("Unknown progress style: " + mProgressStyle); } setUseIntrinsicPadding(useIntrinsicPadding); setShowProgressBackground(showProgressBackground); }