discord-jadx/app/src/main/java/com/discord/utilities/color/ColorCompatKt.java

49 lines
1.8 KiB
Java

package com.discord.utilities.color;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.core.graphics.drawable.DrawableCompat;
import d0.t.k;
import d0.z.d.m;
/* compiled from: ColorCompat.kt */
public final class ColorCompatKt {
public static final void setDrawableColor(TextView textView, @ColorInt int i) {
m.checkNotNullParameter(textView, "$this$setDrawableColor");
Drawable[] compoundDrawables = textView.getCompoundDrawables();
m.checkNotNullExpressionValue(compoundDrawables, "compoundDrawables");
for (Drawable drawable : k.filterNotNull(compoundDrawables)) {
drawable.setColorFilter(new PorterDuffColorFilter(i, PorterDuff.Mode.SRC_IN));
}
}
public static final void setTint(Drawable drawable, @ColorInt int i, boolean z2) {
m.checkNotNullParameter(drawable, "$this$setTint");
if (!z2) {
drawable.mutate();
}
DrawableCompat.setTint(drawable, i);
}
public static /* synthetic */ void setTint$default(Drawable drawable, int i, boolean z2, int i2, Object obj) {
if ((i2 & 2) != 0) {
z2 = false;
}
setTint(drawable, i, z2);
}
public static final void tintWithColor(ImageView imageView, int i) {
m.checkNotNullParameter(imageView, "$this$tintWithColor");
imageView.setImageTintList(ColorStateList.valueOf(i));
}
public static final void tintWithColorResource(ImageView imageView, int i) {
m.checkNotNullParameter(imageView, "$this$tintWithColorResource");
tintWithColor(imageView, ColorCompat.getColor(imageView, i));
}
}