package o; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.graphics.Outline; import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.os.Build; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Xml; import java.io.IOException; import java.util.Arrays; import org.xmlpull.v1.XmlPullParserException; /* loaded from: classes2.dex */ public final class NiE { public static AttributeSet IW_(Context context, int i, CharSequence charSequence) { int next; try { XmlResourceParser xml = context.getResources().getXml(i); do { next = xml.next(); if (next == 2) { break; } } while (next != 1); if (next != 2) { throw new XmlPullParserException("No start tag found"); } if (!TextUtils.equals(xml.getName(), charSequence)) { StringBuilder sb = new StringBuilder(); sb.append("Must have a <"); sb.append((Object) charSequence); sb.append("> start tag"); throw new XmlPullParserException(sb.toString()); } return Xml.asAttributeSet(xml); } catch (IOException | XmlPullParserException e) { StringBuilder sb2 = new StringBuilder("Can't load badge resource ID #0x"); sb2.append(Integer.toHexString(i)); Resources.NotFoundException notFoundException = new Resources.NotFoundException(sb2.toString()); notFoundException.initCause(e); throw notFoundException; } } public static Drawable IV_(Drawable drawable, ColorStateList colorStateList, PorterDuff.Mode mode) { if (drawable == null) { return null; } if (colorStateList != null) { drawable = Tlu.pI_(drawable).mutate(); if (mode != null) { Tlu.pG_(drawable, mode); } } return drawable; } public static Drawable IU_(Drawable drawable, Drawable drawable2) { int intrinsicHeight; int i; if (drawable == null) { return drawable2; } if (drawable2 == null) { return drawable; } LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{drawable, drawable2}); if (drawable2.getIntrinsicWidth() == -1 || drawable2.getIntrinsicHeight() == -1) { int intrinsicWidth = drawable.getIntrinsicWidth(); intrinsicHeight = drawable.getIntrinsicHeight(); i = intrinsicWidth; } else if (drawable2.getIntrinsicWidth() <= drawable.getIntrinsicWidth() && drawable2.getIntrinsicHeight() <= drawable.getIntrinsicHeight()) { i = drawable2.getIntrinsicWidth(); intrinsicHeight = drawable2.getIntrinsicHeight(); } else { float intrinsicWidth2 = drawable2.getIntrinsicWidth() / drawable2.getIntrinsicHeight(); if (intrinsicWidth2 >= drawable.getIntrinsicWidth() / drawable.getIntrinsicHeight()) { i = drawable.getIntrinsicWidth(); intrinsicHeight = (int) (i / intrinsicWidth2); } else { intrinsicHeight = drawable.getIntrinsicHeight(); i = (int) (intrinsicWidth2 * intrinsicHeight); } } layerDrawable.setLayerSize(1, i, intrinsicHeight); layerDrawable.setLayerGravity(1, 17); return layerDrawable; } public static int[] c(int[] iArr) { for (int i = 0; i < iArr.length; i++) { int i2 = iArr[i]; if (i2 == 16842912) { return iArr; } if (i2 == 0) { int[] iArr2 = (int[]) iArr.clone(); iArr2[i] = 16842912; return iArr2; } } int[] copyOf = Arrays.copyOf(iArr, iArr.length + 1); copyOf[iArr.length] = 16842912; return copyOf; } public static void IX_(Outline outline, Path path) { if (Build.VERSION.SDK_INT >= 30) { outline.setPath(path); return; } if (Build.VERSION.SDK_INT >= 29) { try { outline.setConvexPath(path); } catch (IllegalArgumentException unused) { } } else if (path.isConvex()) { outline.setConvexPath(path); } } }