package com.betaseries.betaseries.utils;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.view.MenuItem;
/**
* Created by kevindejesusferreira on 14/08/15.
*/
public class TintUtils {
/** Sets a color filter on a {@link MenuItem} */
public static void tintDrawable(Drawable drawable, final int color, final int alpha) {
if (drawable != null) {
// If we don't mutate the drawable, then all drawable's with this id will have a color
// filter applied to it.
drawable.mutate();
drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
if (alpha > 0) {
drawable.setAlpha(alpha);
}
}
}
/** Sets a color filter on a {@link MenuItem} */
public static void tintDrawable(Drawable drawable, final int color) {
if (drawable != null) {
// If we don't mutate the drawable, then all drawable's with this id will have a color
// filter applied to it.
drawable.mutate();
drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
}
}