package X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.graphics.drawable.InsetDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import java.io.IOException;
import java.lang.reflect.Method;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/* compiled from: DrawableCompat.java */
/* loaded from: classes.dex */
public final class KQgRr5e_0 {
    public static Method KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static boolean f408KQgRr5e_0;
    public static Method QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public static boolean f409QxJ9d_1;

    public static void KQgRr5e_0(Drawable drawable, boolean z) {
        if (Build.VERSION.SDK_INT >= 19) {
            drawable.setAutoMirrored(z);
        }
    }

    @Deprecated
    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public static void m296QxJ9d_1(Drawable drawable) {
        drawable.jumpToCurrentState();
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public static boolean m297QxJ9d_1(Drawable drawable) {
        if (Build.VERSION.SDK_INT >= 19) {
            return drawable.isAutoMirrored();
        }
        return false;
    }

    public static void KQgRr5e_0(Drawable drawable, float f, float f2) {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.setHotspot(f, f2);
        }
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public static Drawable m295QxJ9d_1(Drawable drawable) {
        int i = Build.VERSION.SDK_INT;
        return i >= 23 ? drawable : i >= 21 ? !(drawable instanceof QxJ9d_1) ? new X6FRs_4(drawable) : drawable : !(drawable instanceof QxJ9d_1) ? new Mqv2r_3(drawable) : drawable;
    }

    public static void KQgRr5e_0(Drawable drawable, int i, int i2, int i3, int i4) {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.setHotspotBounds(i, i2, i3, i4);
        }
    }

    public static void KQgRr5e_0(Drawable drawable, int i) {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.setTint(i);
        } else if (drawable instanceof QxJ9d_1) {
            ((QxJ9d_1) drawable).setTint(i);
        }
    }

    public static int QxJ9d_1(Drawable drawable) {
        int i = Build.VERSION.SDK_INT;
        if (i >= 23) {
            return drawable.getLayoutDirection();
        }
        if (i >= 17) {
            if (!f409QxJ9d_1) {
                try {
                    Method declaredMethod = Drawable.class.getDeclaredMethod("getLayoutDirection", new Class[0]);
                    QxJ9d_1 = declaredMethod;
                    declaredMethod.setAccessible(true);
                } catch (NoSuchMethodException e) {
                    Log.i("DrawableCompat", "Failed to retrieve getLayoutDirection() method", e);
                }
                f409QxJ9d_1 = true;
            }
            Method method = QxJ9d_1;
            if (method != null) {
                try {
                    return ((Integer) method.invoke(drawable, new Object[0])).intValue();
                } catch (Exception e2) {
                    Log.i("DrawableCompat", "Failed to invoke getLayoutDirection() via reflection", e2);
                    QxJ9d_1 = null;
                }
            }
        }
        return 0;
    }

    public static void KQgRr5e_0(Drawable drawable, ColorStateList colorStateList) {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.setTintList(colorStateList);
        } else if (drawable instanceof QxJ9d_1) {
            ((QxJ9d_1) drawable).setTintList(colorStateList);
        }
    }

    public static void KQgRr5e_0(Drawable drawable, PorterDuff.Mode mode) {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.setTintMode(mode);
        } else if (drawable instanceof QxJ9d_1) {
            ((QxJ9d_1) drawable).setTintMode(mode);
        }
    }

    public static int KQgRr5e_0(Drawable drawable) {
        if (Build.VERSION.SDK_INT >= 19) {
            return drawable.getAlpha();
        }
        return 0;
    }

    public static void KQgRr5e_0(Drawable drawable, Resources.Theme theme) {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.applyTheme(theme);
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static boolean m293KQgRr5e_0(Drawable drawable) {
        if (Build.VERSION.SDK_INT >= 21) {
            return drawable.canApplyTheme();
        }
        return false;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static ColorFilter m290KQgRr5e_0(Drawable drawable) {
        if (Build.VERSION.SDK_INT >= 21) {
            return drawable.getColorFilter();
        }
        return null;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static void m292KQgRr5e_0(Drawable drawable) {
        DrawableContainer.DrawableContainerState drawableContainerState;
        int i = Build.VERSION.SDK_INT;
        if (i >= 23) {
            drawable.clearColorFilter();
        } else if (i >= 21) {
            drawable.clearColorFilter();
            if (drawable instanceof InsetDrawable) {
                m292KQgRr5e_0(((InsetDrawable) drawable).getDrawable());
            } else if (drawable instanceof PGPF6hQ_2) {
                m292KQgRr5e_0(((PGPF6hQ_2) drawable).KQgRr5e_0());
            } else if ((drawable instanceof DrawableContainer) && (drawableContainerState = (DrawableContainer.DrawableContainerState) ((DrawableContainer) drawable).getConstantState()) != null) {
                int childCount = drawableContainerState.getChildCount();
                for (int i2 = 0; i2 < childCount; i2++) {
                    Drawable child = drawableContainerState.getChild(i2);
                    if (child != null) {
                        m292KQgRr5e_0(child);
                    }
                }
            }
        } else {
            drawable.clearColorFilter();
        }
    }

    public static void KQgRr5e_0(Drawable drawable, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
        if (Build.VERSION.SDK_INT >= 21) {
            drawable.inflate(resources, xmlPullParser, attributeSet, theme);
        } else {
            drawable.inflate(resources, xmlPullParser, attributeSet);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static <T extends Drawable> T m291KQgRr5e_0(Drawable drawable) {
        return drawable instanceof PGPF6hQ_2 ? (T) ((PGPF6hQ_2) drawable).KQgRr5e_0() : drawable;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static boolean m294KQgRr5e_0(Drawable drawable, int i) {
        int i2 = Build.VERSION.SDK_INT;
        if (i2 >= 23) {
            return drawable.setLayoutDirection(i);
        }
        if (i2 >= 17) {
            if (!f408KQgRr5e_0) {
                try {
                    Method declaredMethod = Drawable.class.getDeclaredMethod("setLayoutDirection", Integer.TYPE);
                    KQgRr5e_0 = declaredMethod;
                    declaredMethod.setAccessible(true);
                } catch (NoSuchMethodException e) {
                    Log.i("DrawableCompat", "Failed to retrieve setLayoutDirection(int) method", e);
                }
                f408KQgRr5e_0 = true;
            }
            Method method = KQgRr5e_0;
            if (method != null) {
                try {
                    method.invoke(drawable, Integer.valueOf(i));
                    return true;
                } catch (Exception e2) {
                    Log.i("DrawableCompat", "Failed to invoke setLayoutDirection(int) via reflection", e2);
                    KQgRr5e_0 = null;
                }
            }
        }
        return false;
    }
}
