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;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class V7 {
    public static final PorterDuff.Mode b = PorterDuff.Mode.SRC_IN;
    public static V7 c;
    public C2680v20 a;

    public static synchronized V7 a() {
        try {
            if (c == null) {
                d();
            }
        } catch (Throwable th) {
            throw th;
        }
        return c;
    }

    public static synchronized PorterDuffColorFilter c(int i, PorterDuff.Mode mode) {
        return C2680v20.e(i, mode);
    }

    public static synchronized void d() {
        if (c == null) {
            V7 v7 = new V7();
            c = v7;
            v7.a = C2680v20.b();
            C2680v20 c2680v20 = c.a;
            U7 u7 = new U7();
            synchronized (c2680v20) {
                c2680v20.e = u7;
            }
        }
    }

    public static void e(Drawable drawable, C1794ll c1794ll, int[] iArr) {
        PorterDuff.Mode mode = C2680v20.f;
        int[] state = drawable.getState();
        if (drawable.mutate() == drawable) {
            if ((drawable instanceof LayerDrawable) && drawable.isStateful()) {
                drawable.setState(new int[0]);
                drawable.setState(state);
            }
            boolean z = c1794ll.b;
            if (!z && !c1794ll.a) {
                drawable.clearColorFilter();
                return;
            }
            PorterDuffColorFilter porterDuffColorFilterE = null;
            ColorStateList colorStateList = z ? (ColorStateList) c1794ll.c : null;
            PorterDuff.Mode mode2 = c1794ll.a ? (PorterDuff.Mode) c1794ll.d : C2680v20.f;
            if (colorStateList != null && mode2 != null) {
                porterDuffColorFilterE = C2680v20.e(colorStateList.getColorForState(iArr, 0), mode2);
            }
            drawable.setColorFilter(porterDuffColorFilterE);
        }
    }

    public final synchronized Drawable b(Context context, int i) {
        return this.a.c(context, i);
    }
}
