List of usage examples for android.graphics.drawable Drawable isStateful
public boolean isStateful()
From source file:com.bilibili.magicasakura.widgets.AppCompatCompoundDrawableHelper.java
private Drawable applySupportCompoundDrawableTint(int position) { Drawable originDrawable = ((TextView) mView).getCompoundDrawables()[position]; Drawable compoundDrawable = originDrawable; TintInfo tintInfo = mCompoundDrawableTintInfos[position]; if (compoundDrawable != null && tintInfo != null && tintInfo.mHasTintList) { compoundDrawable = DrawableCompat.wrap(compoundDrawable); compoundDrawable.mutate();/*from w w w . jav a 2 s . c om*/ if (tintInfo.mHasTintList) { DrawableCompat.setTintList(compoundDrawable, tintInfo.mTintList); } if (tintInfo.mHasTintMode) { DrawableCompat.setTintMode(compoundDrawable, tintInfo.mTintMode); } if (compoundDrawable.isStateful()) { compoundDrawable.setState(originDrawable.getState()); } return compoundDrawable; } return originDrawable; }
From source file:android.support.v7.widget.AppCompatCompoundButtonHelper.java
void applyButtonTint() { Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(mView); if (buttonDrawable != null && (mHasButtonTint || mHasButtonTintMode)) { buttonDrawable = DrawableCompat.wrap(buttonDrawable); buttonDrawable = buttonDrawable.mutate(); if (mHasButtonTint) { DrawableCompat.setTintList(buttonDrawable, mButtonTintList); }/* w ww. j a v a 2 s .co m*/ if (mHasButtonTintMode) { DrawableCompat.setTintMode(buttonDrawable, mButtonTintMode); } // The drawable (or one of its children) may not have been // stateful before applying the tint, so let's try again. if (buttonDrawable.isStateful()) { buttonDrawable.setState(mView.getDrawableState()); } mView.setButtonDrawable(buttonDrawable); } }
From source file:com.bilibili.magicasakura.widgets.AppCompatForegroundHelper.java
private boolean applySupportForegroundTint() { Drawable foregroundDrawable = getForeground(); if (foregroundDrawable != null && mForegroundTintInfo != null && mForegroundTintInfo.mHasTintList) { foregroundDrawable = DrawableCompat.wrap(foregroundDrawable); foregroundDrawable = foregroundDrawable.mutate(); if (mForegroundTintInfo.mHasTintList) { DrawableCompat.setTintList(foregroundDrawable, mForegroundTintInfo.mTintList); }/*from w ww .j a v a 2 s. com*/ if (mForegroundTintInfo.mHasTintMode) { DrawableCompat.setTintMode(foregroundDrawable, mForegroundTintInfo.mTintMode); } if (foregroundDrawable.isStateful()) { foregroundDrawable.setState(mView.getDrawableState()); } setForegroundDrawable(foregroundDrawable); return true; } return false; }
From source file:com.bilibili.magicasakura.widgets.AppCompatBackgroundHelper.java
private boolean applySupportBackgroundTint() { Drawable backgroundDrawable = mView.getBackground(); if (backgroundDrawable != null && mBackgroundTintInfo != null && mBackgroundTintInfo.mHasTintList) { backgroundDrawable = DrawableCompat.wrap(backgroundDrawable); backgroundDrawable = backgroundDrawable.mutate(); if (mBackgroundTintInfo.mHasTintList) { DrawableCompat.setTintList(backgroundDrawable, mBackgroundTintInfo.mTintList); }//from w w w. j a va2 s . c o m if (mBackgroundTintInfo.mHasTintMode) { DrawableCompat.setTintMode(backgroundDrawable, mBackgroundTintInfo.mTintMode); } if (backgroundDrawable.isStateful()) { backgroundDrawable.setState(mView.getDrawableState()); } setBackgroundDrawable(backgroundDrawable); return true; } return false; }
From source file:com.bilibili.magicasakura.widgets.AppCompatCompoundButtonHelper.java
public boolean applySupportButtonDrawableTint() { Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable((CompoundButton) mView); if (buttonDrawable != null && mCompoundButtonTintInfo != null && mCompoundButtonTintInfo.mHasTintList) { buttonDrawable = DrawableCompat.wrap(buttonDrawable); buttonDrawable = buttonDrawable.mutate(); if (mCompoundButtonTintInfo.mHasTintList) { DrawableCompat.setTintList(buttonDrawable, mCompoundButtonTintInfo.mTintList); }// ww w. ja v a2 s.c o m if (mCompoundButtonTintInfo.mHasTintMode) { DrawableCompat.setTintMode(buttonDrawable, mCompoundButtonTintInfo.mTintMode); } // The drawable (or one of its children) may not have been // stateful before applying the tint, so let's try again. if (buttonDrawable.isStateful()) { buttonDrawable.setState(mView.getDrawableState()); } setButtonDrawable(buttonDrawable); return true; } return false; }
From source file:com.shizhefei.view.largeimage.LargeImageView.java
private void updateDrawable(Drawable d) { if (mDrawable != null) { mDrawable.setCallback(null);//w w w .ja v a 2 s .c o m unscheduleDrawable(mDrawable); } mDrawable = d; if (d != null) { d.setCallback(this); DrawableCompat.setLayoutDirection(d, DrawableCompat.getLayoutDirection(d)); if (d.isStateful()) { d.setState(getDrawableState()); } d.setVisible(getVisibility() == VISIBLE, true); d.setLevel(mLevel); mDrawableWidth = d.getIntrinsicWidth(); mDrawableHeight = d.getIntrinsicHeight(); } else { mDrawableWidth = mDrawableHeight = -1; } }
From source file:android.support.designox.widget.CollapsingToolbarLayout.java
@Override protected void drawableStateChanged() { super.drawableStateChanged(); final int[] state = getDrawableState(); boolean changed = false; Drawable d = mStatusBarScrim; if (d != null && d.isStateful()) { changed |= d.setState(state);/* w w w .j a v a 2 s . c om*/ } d = mContentScrim; if (d != null && d.isStateful()) { changed |= d.setState(state); } if (changed) { invalidate(); } }
From source file:am.widget.basetabstrip.BaseTabStrip.java
@Override protected void drawableStateChanged() { final float downMotionX = tabStripGestureDetector.getDownMotionX(); final float downMotionY = tabStripGestureDetector.getDownMotionY(); int position = pointToPosition(downMotionX, downMotionY); if (position >= 0 && position < mTabItemBackgrounds.size()) { Drawable tag = mTabItemBackgrounds.get(position); DrawableCompat.setHotspot(tag, getHotspotX(tag, position, downMotionX, downMotionY), getHotspotY(tag, position, downMotionX, downMotionY)); if (tag.isStateful()) { tag.setState(getDrawableState()); }/*from ww w. j a va 2s . c om*/ } super.drawableStateChanged(); }
From source file:android.support.design.widget.CollapsingToolbarLayout.java
@Override protected void drawableStateChanged() { super.drawableStateChanged(); final int[] state = getDrawableState(); boolean changed = false; Drawable d = mStatusBarScrim; if (d != null && d.isStateful()) { changed |= d.setState(state);//from w ww. j a v a 2 s . c o m } d = mContentScrim; if (d != null && d.isStateful()) { changed |= d.setState(state); } if (mCollapsingTextHelper != null) { changed |= mCollapsingTextHelper.setState(state); } if (changed) { invalidate(); } }
From source file:bk.vinhdo.taxiads.utils.view.SlidingLayer.java
@Override protected void drawableStateChanged() { super.drawableStateChanged(); final Drawable d = mShadowDrawable; if (d != null && d.isStateful()) { d.setState(getDrawableState());//from w w w. j a v a 2s . c o m } }