@Override public void setTint(int tintColor) { if (mDrawable instanceof TintableDrawable) { //noinspection RedundantCast ((TintableDrawable) mDrawable).setTint(tintColor); } else { Log.w(TAG, "Drawable did not implement TintableDrawable, it won't be tinted below" + " Lollipop"); super.setTint(tintColor); } }
@Override public void setTintList(ColorStateList tint) { if (mDrawable instanceof TintableDrawable) { //noinspection RedundantCast ((TintableDrawable) mDrawable).setTintList(tint); } else { Log.w(TAG, "Drawable did not implement TintableDrawable, it won't be tinted below" + " Lollipop"); super.setTintList(tint); } }
@Override public void setTintMode(PorterDuff.Mode tintMode) { if (mDrawable instanceof TintableDrawable) { //noinspection RedundantCast ((TintableDrawable) mDrawable).setTintMode(tintMode); } else { Log.w(TAG, "Drawable did not implement TintableDrawable, it won't be tinted below" + " Lollipop"); super.setTintMode(tintMode); } }
if (drawable instanceof TintableDrawable) { ((TintableDrawable) drawable).setTintList(tintList); } else { logDrawableTintWarning(); if (drawable instanceof TintableDrawable) { ((TintableDrawable) drawable).setTintMode(tintMode); } else { logDrawableTintWarning();
private static Drawable createLayerDrawableWithTintColor(int tileRes, int tintColor, Context context) { TileDrawable drawable = new TileDrawable(AppCompatResources.getDrawable(context, tileRes)); drawable.mutate(); //noinspection RedundantCast ((TintableDrawable) drawable).setTint(tintColor); return drawable; }