List of usage examples for android.graphics.drawable Drawable isStateful
public boolean isStateful()
From source file:com.facebook.litho.ComponentHostUtils.java
/** * Sets the state on a drawable if it is clickable or should duplicate its parent's state. *///from w ww. j av a 2 s .c o m static void maybeSetDrawableState(View view, Drawable drawable, int flags, NodeInfo nodeInfo) { final boolean shouldSetState = (nodeInfo != null && nodeInfo.hasTouchEventHandlers()) || MountItem.isDuplicateParentState(flags); if (shouldSetState && drawable.isStateful()) { drawable.setState(view.getDrawableState()); } }
From source file:me.henrytao.mdcore.core.MdCompat.java
public static Drawable createDrawableTint(Drawable drawable, int[] drawableState, ColorStateList tintList, PorterDuff.Mode tintMode) {// w w w . j a v a2 s .co m if (drawable != null && (tintList != null || tintMode != null)) { drawable = DrawableCompat.wrap(drawable).mutate(); if (tintList != null) { DrawableCompat.setTintList(drawable, tintList); } if (tintMode != null) { DrawableCompat.setTintMode(drawable, tintMode); } if (drawable.isStateful() && drawableState != null) { drawable.setState(drawableState); } } return drawable; }
From source file:org.getlantern.firetweet.view.MessageCardItemFrameLayout.java
@Override protected void drawableStateChanged() { super.drawableStateChanged(); final Drawable d = getBackground(); if (d != null && d.isStateful()) { final int[] state = getDrawableState(); d.setState(state);//ww w . ja va 2 s . c o m final Drawable current = d.getCurrent(); if (current instanceof TransitionDrawable) { final TransitionDrawable td = (TransitionDrawable) current; if (ArrayUtils.contains(state, android.R.attr.state_pressed)) { td.startTransition(ViewConfiguration.getLongPressTimeout()); } else { td.resetTransition(); } } } }
From source file:android.support.v7.widget.AppCompatSeekBarHelper.java
void drawableStateChanged() { final Drawable tickMark = mTickMark; if (tickMark != null && tickMark.isStateful() && tickMark.setState(mView.getDrawableState())) { mView.invalidateDrawable(tickMark); }//from www .j av a 2 s.c o m }
From source file:com.shizhefei.view.largeimage.UpdateImageView.java
@Override protected void drawableStateChanged() { super.drawableStateChanged(); Drawable d = mDrawable; if (d != null && d.isStateful()) { d.setState(getDrawableState());/*w w w. j av a 2 s. c om*/ } }
From source file:android.support.v7.widget.AppCompatSeekBarHelper.java
void setTickMark(@Nullable Drawable tickMark) { if (mTickMark != null) { mTickMark.setCallback(null);//w w w . ja va 2s .c o m } mTickMark = tickMark; if (tickMark != null) { tickMark.setCallback(mView); DrawableCompat.setLayoutDirection(tickMark, ViewCompat.getLayoutDirection(mView)); if (tickMark.isStateful()) { tickMark.setState(mView.getDrawableState()); } applyTickMarkTint(); } mView.invalidate(); }
From source file:com.facebook.litho.reference.DrawableResourcesCache.java
public void release(Drawable drawable, int resId) { SimplePoolWithCount<Drawable> drawablesPool = mDrawableCache.get(resId); if (drawablesPool == null) { drawablesPool = new SimplePoolWithCount<>(DRAWABLES_POOL_MAX_ITEMS); mDrawableCache.put(resId, drawablesPool); }/*from www. java2s . c om*/ // Reset a stateful drawable, and its animations, before being released. if (drawable.isStateful()) { drawable.setState(StateSet.WILD_CARD); if (SDK_INT >= HONEYCOMB) { drawable.jumpToCurrentState(); } } drawablesPool.release(drawable); }
From source file:com.bilibili.magicasakura.widgets.AppCompatImageHelper.java
private boolean applySupportImageTint() { Drawable image = ((ImageView) mView).getDrawable(); if (image != null && mImageTintInfo != null && mImageTintInfo.mHasTintList) { Drawable tintDrawable = image.mutate(); tintDrawable = DrawableCompat.wrap(tintDrawable); if (mImageTintInfo.mHasTintList) { DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList); }//from w ww. ja va2 s . co m if (mImageTintInfo.mHasTintMode) { DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode); } if (tintDrawable.isStateful()) { tintDrawable.setState(mView.getDrawableState()); } setImageDrawable(tintDrawable); if (image == tintDrawable) { tintDrawable.invalidateSelf(); } return true; } return false; }
From source file:com.shizhefei.view.largeimage.UpdateImageView.java
private void updateDrawable(Drawable d) { if (mDrawable != null) { mDrawable.setCallback(null);//from w w w .ja v a 2s .c om 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(); // applyImageTint(); // applyColorMod(); // // configureBounds(); } else { mDrawableWidth = mDrawableHeight = -1; } }
From source file:com.guoxiaoxing.cloud.music.magicasakura.widgets.AppCompatImageHelper.java
private boolean applySupportImageTint() { Drawable image = ((ImageView) mView).getDrawable(); AnimationDrawable animationDrawable = null; if (image instanceof AnimationDrawable) { Log.e("drawable", "is animationdrawable"); animationDrawable = ((AnimationDrawable) image); //image = animationDrawable; }// www. java 2s.c o m if (image != null && mImageTintInfo != null && mImageTintInfo.mHasTintList) { if (animationDrawable != null) { Log.e("drawable", "is animationdrawable not null"); Drawable tintDrawable = animationDrawable; Log.e("drawable", "start0"); tintDrawable = DrawableCompat.wrap(tintDrawable); Log.e("drawable", "start1"); if (mImageTintInfo.mHasTintList) { DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList); } if (mImageTintInfo.mHasTintMode) { DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode); } if (tintDrawable.isStateful()) { tintDrawable.setState(mView.getDrawableState()); } tintDrawable = DrawableCompat.unwrap(tintDrawable); setImageDrawable(tintDrawable); if (image == tintDrawable) { Log.e("drawable", "invalidateself"); // tintDrawable.invalidateSelf(); } return true; } else { Drawable tintDrawable = image.mutate(); tintDrawable = DrawableCompat.wrap(tintDrawable); if (mImageTintInfo.mHasTintList) { DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList); } if (mImageTintInfo.mHasTintMode) { DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode); } if (tintDrawable.isStateful()) { tintDrawable.setState(mView.getDrawableState()); } setImageDrawable(tintDrawable); if (image == tintDrawable) { tintDrawable.invalidateSelf(); } return true; } } return false; }