package o; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.util.TypedValue; import java.lang.ref.WeakReference; import java.util.WeakHashMap; import o.kli; /* loaded from: classes.dex */ public final class KPD { private static KPD d; HBt b; final WeakHashMap>> c = new WeakHashMap<>(0); private WeakHashMap> f; private boolean g; private TypedValue h; private DFj i; private static final PorterDuff.Mode e = PorterDuff.Mode.SRC_IN; private static final LWm a = new LWm(); /* loaded from: classes.dex */ public interface HBt { Drawable iY_(KPD kpd, Context context, int i); ColorStateList iZ_(Context context, int i); PorterDuff.Mode ja_(int i); boolean jb_(Context context, int i, Drawable drawable); boolean jc_(Context context, int i, Drawable drawable); } public static KPD d() { KPD kpd; synchronized (KPD.class) { if (d == null) { d = new KPD(); } kpd = d; } return kpd; } public final Drawable iT_(Context context, int i) { Drawable iU_; synchronized (this) { iU_ = iU_(context, i, false); } return iU_; } /* JADX INFO: Access modifiers changed from: package-private */ public final Drawable iU_(Context context, int i, boolean z) { Drawable iP_; synchronized (this) { if (!this.g) { this.g = true; Drawable iT_ = iT_(context, kli.IeS.abc_vector_test); if (iT_ == null || (!(iT_ instanceof C16078kwa) && !"android.graphics.drawable.VectorDrawable".equals(iT_.getClass().getName()))) { this.g = false; throw new IllegalStateException("This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat."); } } if (this.h == null) { this.h = new TypedValue(); } TypedValue typedValue = this.h; context.getResources().getValue(i, typedValue, true); long j = (typedValue.assetCookie << 32) | typedValue.data; iP_ = iP_(context, j); if (iP_ == null) { HBt hBt = this.b; iP_ = hBt == null ? null : hBt.iY_(this, context, i); if (iP_ != null) { iP_.setChangingConfigurations(typedValue.changingConfigurations); iO_(context, j, iP_); } } if (iP_ == null) { iP_ = nMh.getDrawable(context, i); } if (iP_ != null) { iP_ = iR_(context, i, z, iP_); } if (iP_ != null) { FIj.hX_(iP_); } } return iP_; } private Drawable iR_(Context context, int i, boolean z, Drawable drawable) { ColorStateList iV_ = iV_(context, i); if (iV_ != null) { FIj.b(); Drawable pI_ = Tlu.pI_(drawable.mutate()); Tlu.pF_(pI_, iV_); HBt hBt = this.b; PorterDuff.Mode ja_ = hBt != null ? hBt.ja_(i) : null; if (ja_ == null) { return pI_; } Tlu.pG_(pI_, ja_); return pI_; } HBt hBt2 = this.b; if (hBt2 != null && hBt2.jb_(context, i, drawable)) { return drawable; } HBt hBt3 = this.b; if ((hBt3 == null || !hBt3.jc_(context, i, drawable)) && z) { return null; } return drawable; } private Drawable iP_(Context context, long j) { synchronized (this) { C0667Ltg> c0667Ltg = this.c.get(context); if (c0667Ltg == null) { return null; } WeakReference c = c0667Ltg.c(j); if (c != null) { Drawable.ConstantState constantState = c.get(); if (constantState != null) { return constantState.newDrawable(context.getResources()); } c0667Ltg.e(j); } return null; } } private boolean iO_(Context context, long j, Drawable drawable) { synchronized (this) { Drawable.ConstantState constantState = drawable.getConstantState(); if (constantState == null) { return false; } C0667Ltg> c0667Ltg = this.c.get(context); if (c0667Ltg == null) { c0667Ltg = new C0667Ltg<>(); this.c.put(context, c0667Ltg); } c0667Ltg.c(j, new WeakReference<>(constantState)); return true; } } /* JADX INFO: Access modifiers changed from: package-private */ public final Drawable iW_(Context context, Itu itu, int i) { synchronized (this) { Drawable jd_ = itu.jd_(i); if (jd_ == null) { return null; } return iR_(context, i, false, jd_); } } /* JADX INFO: Access modifiers changed from: package-private */ public final ColorStateList iV_(Context context, int i) { ColorStateList e2; VOL vol; synchronized (this) { WeakHashMap> weakHashMap = this.f; ColorStateList colorStateList = null; e2 = (weakHashMap == null || (vol = weakHashMap.get(context)) == null) ? null : vol.e(i); if (e2 == null) { HBt hBt = this.b; if (hBt != null) { colorStateList = hBt.iZ_(context, i); } if (colorStateList != null) { if (this.f == null) { this.f = new WeakHashMap<>(); } VOL vol2 = this.f.get(context); if (vol2 == null) { vol2 = new VOL<>(); this.f.put(context, vol2); } vol2.b(i, colorStateList); } e2 = colorStateList; } } return e2; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class LWm extends pKi { public LWm() { super(6); } static int iX_(int i, PorterDuff.Mode mode) { return ((i + 31) * 31) + mode.hashCode(); } } /* JADX INFO: Access modifiers changed from: package-private */ public static void iS_(Drawable drawable, C16821rXR c16821rXR, int[] iArr) { int[] state = drawable.getState(); FIj.b(); if (drawable.mutate() != drawable) { return; } if ((drawable instanceof LayerDrawable) && drawable.isStateful()) { drawable.setState(new int[0]); drawable.setState(state); } if (c16821rXR.b || c16821rXR.a) { PorterDuffColorFilter porterDuffColorFilter = null; ColorStateList colorStateList = c16821rXR.b ? c16821rXR.c : null; PorterDuff.Mode mode = c16821rXR.a ? c16821rXR.d : e; if (colorStateList != null && mode != null) { porterDuffColorFilter = iQ_(colorStateList.getColorForState(iArr, 0), mode); } drawable.setColorFilter(porterDuffColorFilter); return; } drawable.clearColorFilter(); } public static PorterDuffColorFilter iQ_(int i, PorterDuff.Mode mode) { PorterDuffColorFilter porterDuffColorFilter; synchronized (KPD.class) { LWm lWm = a; porterDuffColorFilter = lWm.get(Integer.valueOf(LWm.iX_(i, mode))); if (porterDuffColorFilter == null) { porterDuffColorFilter = new PorterDuffColorFilter(i, mode); lWm.put(Integer.valueOf(LWm.iX_(i, mode)), porterDuffColorFilter); } } return porterDuffColorFilter; } }