List of usage examples for android.graphics.drawable Drawable invalidateSelf
public void invalidateSelf()
From source file:Main.java
public static Drawable setClearFilter(Drawable draw) { draw.clearColorFilter(); draw.invalidateSelf(); return draw; }
From source file:Main.java
public static Drawable setAlpha(Drawable draw, int alpha) { draw.setAlpha(alpha);// ww w . j a v a 2s . c o m draw.invalidateSelf(); return draw; }
From source file:Main.java
public static Drawable setMatrixColorFilter(ColorMatrix matrix, Drawable draw) { draw.setColorFilter(new ColorMatrixColorFilter(matrix)); draw.invalidateSelf(); return draw;/* w w w . ja va2s . c o m*/ }
From source file:Main.java
public static Drawable setColorFilter(Drawable draw, int color, PorterDuff.Mode mod) { draw.setColorFilter(new PorterDuffColorFilter(color, mod)); draw.invalidateSelf(); return draw;//from w w w. j av a 2 s. co m }
From source file:org.opensilk.common.ui.widget.CircleImageView.java
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); radius = Math.max(w, h) * 2; // *2 what? id think it would be /2; Drawable d = getDrawable(); if (d != null) { if (d instanceof RoundedBitmapDrawable) { ((RoundedBitmapDrawable) d).setCornerRadius(radius); d.invalidateSelf(); } else if (d instanceof TransitionDrawable) { //Todo anyway to check size of transitiondrawable? Drawable d1 = ((TransitionDrawable) d).getDrawable(1); if (d1 instanceof RoundedBitmapDrawable) { ((RoundedBitmapDrawable) d1).setCornerRadius(radius); d.invalidateSelf();/*from w ww. j a va 2 s. c o m*/ } } } }
From source file:com.bilibili.magicasakura.utils.TintManager.java
public static void tintViewDrawable(View view, Drawable drawable, TintInfo tint) { if (view == null || drawable == null) return;//from ww w . j ava 2 s .c o m if (tint.mHasTintList || tint.mHasTintMode) { drawable.mutate(); if (drawable instanceof ColorDrawable) { ((ColorDrawable) drawable).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList .getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor()))); } else { drawable.setColorFilter( createTintFilter(view.getContext(), tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, view.getDrawableState())); } } else { drawable.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 23) { // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter // has changed, so we need to force an invalidation drawable.invalidateSelf(); } }
From source file:com.bilibili.magicasakura.utils.TintManager.java
public static void tintViewBackground(View view, com.bilibili.magicasakura.utils.TintInfo tint) { Drawable background; if (view == null || (background = view.getBackground()) == null) return;//w w w. j a v a 2 s. c om if (tint.mHasTintList || tint.mHasTintMode) { background.mutate(); if (background instanceof ColorDrawable) { ((ColorDrawable) background).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList .getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor()))); } else { background.setColorFilter( createTintFilter(view.getContext(), tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, view.getDrawableState())); } } else { background.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 23) { // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter // has changed, so we need to force an invalidation background.invalidateSelf(); } }
From source file:poche.fm.potunes.utils.TintManager.java
public static void tintViewBackground(View view, TintInfo tint) { Drawable background; if (view == null || (background = view.getBackground()) == null) return;/* w w w .j a v a2 s. co m*/ if (tint.mHasTintList || tint.mHasTintMode) { background.mutate(); if (background instanceof ColorDrawable) { ((ColorDrawable) background).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList .getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor()))); } else { background.setColorFilter( createTintFilter(view.getContext(), tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, view.getDrawableState())); } } else { background.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 23) { // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter // has changed, so we need to force an invalidation background.invalidateSelf(); } }
From source file:com.max.library.view.v7.AppCompatDrawableManager.java
public static void tintDrawable(Drawable drawable, TintInfo tint, int[] state) { if (shouldMutateBackground(drawable) && drawable.mutate() != drawable) { Log.d(TAG, "Mutated drawable is not the same instance as the input."); return;/*from w w w .j a v a2 s.c om*/ } if (tint.mHasTintList || tint.mHasTintMode) { drawable.setColorFilter(createTintFilter(tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, state)); } else { drawable.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 23) { // Pre-v23 there is no guarantee that a state change will invoke an invalidation, // so we force it ourselves drawable.invalidateSelf(); } }
From source file:android.support.v7.widget.AppCompatDrawableManager.java
public static void tintDrawable(Drawable drawable, TintInfo tint, int[] state) { if (DrawableUtils.canSafelyMutateDrawable(drawable) && drawable.mutate() != drawable) { Log.d(TAG, "Mutated drawable is not the same instance as the input."); return;/*ww w. ja v a2 s . co m*/ } if (tint.mHasTintList || tint.mHasTintMode) { drawable.setColorFilter(createTintFilter(tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, state)); } else { drawable.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 23) { // Pre-v23 there is no guarantee that a state change will invoke an invalidation, // so we force it ourselves drawable.invalidateSelf(); } }