List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:io.github.hidroh.materialistic.widget.IconButton.java
public IconButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setBackgroundResource(AppUtils.getThemedResId(context, R.attr.selectableItemBackgroundBorderless)); TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.IconButton, 0, 0); int colorDisabled = ContextCompat.getColor(context, AppUtils.getThemedResId(context, android.R.attr.textColorSecondary)); int colorDefault = ContextCompat.getColor(context, AppUtils.getThemedResId(context, android.R.attr.textColorPrimary)); int colorEnabled = ta.getColor(R.styleable.IconButton_tint, colorDefault); mColorStateList = new ColorStateList(STATES, new int[] { colorEnabled, colorDisabled }); mTinted = ta.hasValue(R.styleable.IconButton_tint); if (getSuggestedMinimumWidth() == 0) { setMinimumWidth(context.getResources().getDimensionPixelSize(R.dimen.icon_button_width)); }//from ww w . j a v a2 s . co m setScaleType(ScaleType.CENTER); setImageDrawable(getDrawable()); ta.recycle(); }
From source file:me.henrytao.mdcore.core.MdLayoutInflaterFactory.java
protected void supportImageView(Context context, ImageView imageView, AttributeSet attrs) { if (imageView == null) { return;//from w w w. j a v a 2s . c om } boolean isEnabled = true; TypedArray a = context.getTheme().obtainStyledAttributes(attrs, new int[] { R.attr.enabled }, 0, 0); try { isEnabled = a.getBoolean(0, true); } catch (Exception ignore) { } a.recycle(); imageView.setEnabled(isEnabled); }
From source file:com.example.android.leanback.StringPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Log.d(TAG, "onCreateViewHolder"); final Context context = parent.getContext(); TextView tv = new TextView(context); tv.setFocusable(true);//from ww w . ja v a 2 s . co m tv.setFocusableInTouchMode(true); tv.setBackground( ResourcesCompat.getDrawable(context.getResources(), R.drawable.text_bg, context.getTheme())); return new ViewHolder(tv); }
From source file:me.henrytao.mdcore.core.MdLayoutInflaterFactory.java
protected void supportCheckBox(Context context, CheckBox checkBox, AttributeSet attrs) { if (checkBox == null) { return;//from ww w. jav a2 s. co m } Drawable drawable = null; TypedArray a = context.getTheme().obtainStyledAttributes(attrs, new int[] { R.attr.srcCompat }, 0, 0); try { int resId = a.getResourceId(0, 0); if (resId > 0) { drawable = MdVectorDrawableCompat.create(context, resId); } } catch (Exception ignore) { } a.recycle(); if (drawable != null) { checkBox.setButtonDrawable(drawable); } }
From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java
private static boolean isGuidedStepTheme(Context context) { int resId = android.support.v17.leanback.R.attr.guidedStepThemeFlag; TypedValue typedValue = new TypedValue(); boolean found = context.getTheme().resolveAttribute(resId, typedValue, true); if (DEBUG)// w w w . j a v a 2 s. com Log.v(TAG, "Found guided step theme flag? " + found); return found && typedValue.type == TypedValue.TYPE_INT_BOOLEAN && typedValue.data != 0; }
From source file:com.example.android.leanback.CardPresenter.java
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { Log.d(TAG, "onBindViewHolder for " + item.toString()); PhotoItem photoItem = (PhotoItem) item; final Context context = viewHolder.view.getContext(); Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), photoItem.getImageResourceId(), context.getTheme()); ((ImageCardView) viewHolder.view).setMainImage(drawable); ((ImageCardView) viewHolder.view).setTitleText(photoItem.getTitle()); if (!TextUtils.isEmpty(photoItem.getContent())) { ((ImageCardView) viewHolder.view).setContentText(photoItem.getContent()); }/* w w w .j a va2 s. com*/ }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
private static Animator createAnimator(View v, int attrId) { Context ctx = v.getContext(); TypedValue typedValue = new TypedValue(); ctx.getTheme().resolveAttribute(attrId, typedValue, true); Animator animator = AnimatorInflater.loadAnimator(ctx, typedValue.resourceId); animator.setTarget(v);/*from w w w . j a va 2 s . c om*/ return animator; }
From source file:com.doctoror.fuckoffmusicplayer.presentation.queue.QueueItemViewHolder.java
@NonNull private Drawable getSelectedBackground(@NonNull final Context context) { if (mSelectedBackground != null) { return mSelectedBackground; }/* ww w . j a va2 s . c o m*/ mSelectedBackground = new LayerDrawable(new Drawable[] { new ColorDrawable(ThemeUtils.getColor(context.getTheme(), android.R.attr.windowBackground)), new ColorDrawable(ContextCompat.getColor(context, R.color.dividerBackground)) }); return mSelectedBackground; }
From source file:com.example.android.leanback.CardPresenter.java
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item, List<Object> payloads) { if (payloads.isEmpty()) { super.onBindViewHolder(viewHolder, item, payloads); } else {//from w w w . j a v a 2 s . c o m PhotoItem photoItem = (PhotoItem) item; Bundle o = (Bundle) payloads.get(0); for (String key : o.keySet()) { if (key.equals(IMAGE)) { final Context context = viewHolder.view.getContext(); Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), photoItem.getImageResourceId(), context.getTheme()); ((ImageCardView) viewHolder.view).setMainImage(drawable); } if (key.equals(CONTENT)) { ((ImageCardView) viewHolder.view).setContentText(photoItem.getContent()); } if (key.equals(TITLE)) { ((ImageCardView) viewHolder.view).setTitleText(photoItem.getTitle()); } } } }
From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java
/** * Loads an {@link Animator} object from a context * * @param context Application context used to access resources * @param id The resource id of the animation to load * @return The animator object reference by the specified id * @throws NotFoundException when the animation cannot be loaded *//*w w w. j ava2s . co m*/ public static Animator loadAnimator(Context context, @AnimatorRes int id) throws NotFoundException { Animator objectAnimator; // Since AVDC will fall back onto AVD when API is >= 24, therefore, PathParser will need // to match the accordingly to be able to call into the right setter/ getter for animation. if (Build.VERSION.SDK_INT >= 24) { objectAnimator = AnimatorInflater.loadAnimator(context, id); } else { objectAnimator = loadAnimator(context, context.getResources(), context.getTheme(), id); } return objectAnimator; }