List of usage examples for android.content.res TypedArray getResourceId
@AnyRes public int getResourceId(@StyleableRes int index, int defValue)
From source file:com.bilibili.magicasakura.widgets.AppCompatImageHelper.java
@SuppressWarnings("ResourceType") @Override// www . j a va2 s. co m void loadFromAttribute(AttributeSet attrs, int defStyleAttr) { TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTRS, defStyleAttr, 0); if (array.hasValue(1)) { mImageTintResId = array.getResourceId(1, 0); if (array.hasValue(2)) { setSupportImageTintMode(DrawableUtils.parseTintMode(array.getInt(2, 0), null)); } setSupportImageTint(mImageTintResId); } else { Drawable image = mTintManager.getDrawable(mImageResId = array.getResourceId(0, 0)); if (image != null) { setImageDrawable(image); } } array.recycle(); }
From source file:com.github.rubensousa.bottomsheetbuilder.BottomSheetBuilder.java
@SuppressWarnings("ResourceType") private void setupThemeColors(TypedArray typedArray) { int backgroundRes = typedArray.getResourceId(0, mBackgroundColor); int textRes = typedArray.getResourceId(1, mItemTextColor); int titleRes = typedArray.getResourceId(2, mTitleTextColor); if (backgroundRes != mBackgroundColor) { mBackgroundColor = ContextCompat.getColor(mContext, backgroundRes); }//from www .j a va2 s .c o m if (titleRes != mTitleTextColor) { mTitleTextColor = ContextCompat.getColor(mContext, titleRes); } if (textRes != mItemTextColor) { mItemTextColor = ContextCompat.getColor(mContext, textRes); } typedArray.recycle(); }
From source file:com.google.blockly.android.ui.TrashCanView.java
public TrashCanView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TrashCanView, 0, 0); try {//w ww . j av a 2 s . co m //noinspection ResourceType setDefaultIcon(a.getResourceId(R.styleable.TrashCanView_defaultIcon, R.drawable.blockly_trash)); setOnHoverIcon(a.getResourceId(R.styleable.TrashCanView_onHoverIcon, R.drawable.blockly_trash_open)); } finally { a.recycle(); } }
From source file:com.bilibili.magicasakura.widgets.AppCompatForegroundHelper.java
@SuppressWarnings("ResourceType") @Override/*from w w w . j a v a 2s . c om*/ void loadFromAttribute(AttributeSet attrs, int defStyleAttr) { TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTR, defStyleAttr, 0); if (array.hasValue(1)) { mForegroundResId = array.getResourceId(1, 0); if (array.hasValue(2)) { setSupportForegroundTintMode(DrawableUtils.parseTintMode(array.getInt(2, 0), null)); } setSupportForegroundTint(mForegroundTintResId); } else { Drawable drawable = mTintManager.getDrawable(mForegroundResId = array.getResourceId(0, 0)); if (drawable != null) { setForegroundDrawable(drawable); } } array.recycle(); }
From source file:com.bilibili.magicasakura.widgets.AppCompatCompoundButtonHelper.java
@SuppressWarnings("ResourceType") @Override/* w ww . j a v a 2s. c o m*/ void loadFromAttribute(AttributeSet attrs, int defStyleAttr) { TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTRS, defStyleAttr, 0); if (array.hasValue(1)) { mCompoundButtonTintResId = array.getResourceId(1, 0); if (array.hasValue(2)) { setSupportButtonDrawableTintMode(DrawableUtils.parseTintMode(array.getInt(2, 0), null)); } setSupportButtonDrawableTint(mCompoundButtonTintResId); } else { Drawable drawable = mTintManager.getDrawable(mCompoundButtonResId = array.getResourceId(0, 0)); if (drawable != null) { setButtonDrawable(drawable); } } array.recycle(); }
From source file:com.bobomee.android.gank.io.widget.CompactTabLayout.java
@SuppressLint("PrivateResource") public CompactTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout, defStyleAttr, R.style.Widget_Design_TabLayout); int tabBackgroundResId = a.getResourceId(R.styleable.TabLayout_tabBackground, 0); a.recycle();/*from w ww.j a v a 2 s. c om*/ INDICATOR_HEIGHT = dpToPx(2); hoverPaint = new Paint(); hoverPaint.setColor(ContextCompat.getColor(context, tabBackgroundResId)); hoverPaint.setStyle(Paint.Style.FILL); tabViews = new ArrayList<>(tabCount); }
From source file:cn.qbcbyb.library.view.PagerTabStrip.java
public PagerTabStrip(Context context, AttributeSet attrs) { super(context, attrs); setWillNotDraw(false);//from ww w . jav a 2 s . c om setOrientation(LinearLayout.HORIZONTAL); // get custom attrs TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerTabStrip); indicatorDrawable = a.getResourceId(R.styleable.PagerTabStrip_indicatorDrawable, R.drawable.pager_indicator); a.recycle(); }
From source file:com.afayear.android.client.activity.DualPaneActivity.java
protected int getPaneBackground() { final TypedArray a = obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); final int background = a.getResourceId(0, 0); a.recycle();/* ww w.j a v a 2s . com*/ return background; }
From source file:com.bilibili.magicasakura.widgets.AppCompatBackgroundHelper.java
@SuppressWarnings("ResourceType") @Override//from w w w .j av a 2 s.c o m void loadFromAttribute(AttributeSet attrs, int defStyleAttr) { initPadding(); TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTR, defStyleAttr, 0); if (array.hasValue(1)) { mBackgroundTintResId = array.getResourceId(1, 0); if (array.hasValue(2)) { setSupportBackgroundTintMode(DrawableUtils.parseTintMode(array.getInt(2, 0), null)); } setSupportBackgroundTint(mBackgroundTintResId); } else { Drawable drawable = mTintManager.getDrawable(mBackgroundResId = array.getResourceId(0, 0)); if (drawable != null) { setBackgroundDrawable(drawable); } } array.recycle(); }
From source file:androidx.navigation.NavGraph.java
@Override public void onInflate(@NonNull Context context, @NonNull AttributeSet attrs) { super.onInflate(context, attrs); TypedArray a = context.getResources().obtainAttributes(attrs, R.styleable.NavGraphNavigator); setStartDestination(a.getResourceId(R.styleable.NavGraphNavigator_startDestination, 0)); a.recycle();/*from w w w.ja v a 2 s. c om*/ }