package androidx.vectordrawable.graphics.drawable; import android.animation.Animator; import android.animation.AnimatorInflater; import android.animation.Keyframe; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.TypeEvaluator; import android.animation.ValueAnimator; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.Path; import android.graphics.PathMeasure; import android.util.AttributeSet; import android.util.TypedValue; import android.util.Xml; import android.view.InflateException; import androidx.annotation.AnimatorRes; import androidx.annotation.RestrictTo; import androidx.core.content.res.TypedArrayUtils; import androidx.core.graphics.PathParser; import com.ironsource.mediationsdk.utils.IronSourceConstants; import java.io.IOException; import java.util.ArrayList; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) /* loaded from: classes.dex */ public class AnimatorInflaterCompat { private static final boolean DBG_ANIMATOR_INFLATER = false; private static final int MAX_NUM_POINTS = 100; private static final String TAG = "AnimatorInflater"; private static final int TOGETHER = 0; private static final int VALUE_TYPE_COLOR = 3; private static final int VALUE_TYPE_FLOAT = 0; private static final int VALUE_TYPE_INT = 1; private static final int VALUE_TYPE_PATH = 2; private static final int VALUE_TYPE_UNDEFINED = 4; private static boolean isColorType(int i) { return i >= 28 && i <= 31; } public static Animator loadAnimator(Context context, @AnimatorRes int i) throws Resources.NotFoundException { return AnimatorInflater.loadAnimator(context, i); } public static Animator loadAnimator(Context context, Resources resources, Resources.Theme theme, @AnimatorRes int i) throws Resources.NotFoundException { return loadAnimator(context, resources, theme, i, 1.0f); } public static Animator loadAnimator(Context context, Resources resources, Resources.Theme theme, @AnimatorRes int i, float f) throws Resources.NotFoundException { XmlResourceParser xmlResourceParser = null; try { try { try { xmlResourceParser = resources.getAnimation(i); return createAnimatorFromXml(context, resources, theme, xmlResourceParser, f); } catch (IOException e) { Resources.NotFoundException notFoundException = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(i)); notFoundException.initCause(e); throw notFoundException; } } catch (XmlPullParserException e2) { Resources.NotFoundException notFoundException2 = new Resources.NotFoundException("Can't load animation resource ID #0x" + Integer.toHexString(i)); notFoundException2.initCause(e2); throw notFoundException2; } } finally { if (xmlResourceParser != null) { xmlResourceParser.close(); } } } public static class PathDataEvaluator implements TypeEvaluator { private PathParser.PathDataNode[] mNodeArray; public PathDataEvaluator() { } public PathDataEvaluator(PathParser.PathDataNode[] pathDataNodeArr) { this.mNodeArray = pathDataNodeArr; } @Override // android.animation.TypeEvaluator public PathParser.PathDataNode[] evaluate(float f, PathParser.PathDataNode[] pathDataNodeArr, PathParser.PathDataNode[] pathDataNodeArr2) { if (!PathParser.canMorph(pathDataNodeArr, pathDataNodeArr2)) { throw new IllegalArgumentException("Can't interpolate between two incompatible pathData"); } if (!PathParser.canMorph(this.mNodeArray, pathDataNodeArr)) { this.mNodeArray = PathParser.deepCopyNodes(pathDataNodeArr); } for (int i = 0; i < pathDataNodeArr.length; i++) { this.mNodeArray[i].interpolatePathDataNode(pathDataNodeArr[i], pathDataNodeArr2[i], f); } return this.mNodeArray; } } private static PropertyValuesHolder getPVH(TypedArray typedArray, int i, int i2, int i3, String str) { int i4; int i5; int i6; float f; PropertyValuesHolder ofFloat; float f2; float f3; PropertyValuesHolder ofObject; TypedValue peekValue = typedArray.peekValue(i2); boolean z = peekValue != null; int i7 = z ? peekValue.type : 0; TypedValue peekValue2 = typedArray.peekValue(i3); boolean z2 = peekValue2 != null; int i8 = z2 ? peekValue2.type : 0; if (i == 4) { i = ((z && isColorType(i7)) || (z2 && isColorType(i8))) ? 3 : 0; } boolean z3 = i == 0; PropertyValuesHolder propertyValuesHolder = null; if (i == 2) { String string = typedArray.getString(i2); String string2 = typedArray.getString(i3); PathParser.PathDataNode[] createNodesFromPathData = PathParser.createNodesFromPathData(string); PathParser.PathDataNode[] createNodesFromPathData2 = PathParser.createNodesFromPathData(string2); if (createNodesFromPathData == null && createNodesFromPathData2 == null) { return null; } if (createNodesFromPathData == null) { if (createNodesFromPathData2 != null) { return PropertyValuesHolder.ofObject(str, new PathDataEvaluator(), createNodesFromPathData2); } return null; } PathDataEvaluator pathDataEvaluator = new PathDataEvaluator(); if (createNodesFromPathData2 != null) { if (!PathParser.canMorph(createNodesFromPathData, createNodesFromPathData2)) { throw new InflateException(" Can't morph from " + string + " to " + string2); } ofObject = PropertyValuesHolder.ofObject(str, pathDataEvaluator, createNodesFromPathData, createNodesFromPathData2); } else { ofObject = PropertyValuesHolder.ofObject(str, pathDataEvaluator, createNodesFromPathData); } return ofObject; } ArgbEvaluator argbEvaluator = i == 3 ? ArgbEvaluator.getInstance() : null; if (z3) { if (z) { if (i7 == 5) { f2 = typedArray.getDimension(i2, 0.0f); } else { f2 = typedArray.getFloat(i2, 0.0f); } if (z2) { if (i8 == 5) { f3 = typedArray.getDimension(i3, 0.0f); } else { f3 = typedArray.getFloat(i3, 0.0f); } ofFloat = PropertyValuesHolder.ofFloat(str, f2, f3); } else { ofFloat = PropertyValuesHolder.ofFloat(str, f2); } } else { if (i8 == 5) { f = typedArray.getDimension(i3, 0.0f); } else { f = typedArray.getFloat(i3, 0.0f); } ofFloat = PropertyValuesHolder.ofFloat(str, f); } propertyValuesHolder = ofFloat; } else if (z) { if (i7 == 5) { i5 = (int) typedArray.getDimension(i2, 0.0f); } else if (isColorType(i7)) { i5 = typedArray.getColor(i2, 0); } else { i5 = typedArray.getInt(i2, 0); } if (z2) { if (i8 == 5) { i6 = (int) typedArray.getDimension(i3, 0.0f); } else if (isColorType(i8)) { i6 = typedArray.getColor(i3, 0); } else { i6 = typedArray.getInt(i3, 0); } propertyValuesHolder = PropertyValuesHolder.ofInt(str, i5, i6); } else { propertyValuesHolder = PropertyValuesHolder.ofInt(str, i5); } } else if (z2) { if (i8 == 5) { i4 = (int) typedArray.getDimension(i3, 0.0f); } else if (isColorType(i8)) { i4 = typedArray.getColor(i3, 0); } else { i4 = typedArray.getInt(i3, 0); } propertyValuesHolder = PropertyValuesHolder.ofInt(str, i4); } if (propertyValuesHolder == null || argbEvaluator == null) { return propertyValuesHolder; } propertyValuesHolder.setEvaluator(argbEvaluator); return propertyValuesHolder; } private static void parseAnimatorFromTypeArray(ValueAnimator valueAnimator, TypedArray typedArray, TypedArray typedArray2, float f, XmlPullParser xmlPullParser) { long namedInt = TypedArrayUtils.getNamedInt(typedArray, xmlPullParser, IronSourceConstants.EVENTS_DURATION, 1, 300); long namedInt2 = TypedArrayUtils.getNamedInt(typedArray, xmlPullParser, "startOffset", 2, 0); int namedInt3 = TypedArrayUtils.getNamedInt(typedArray, xmlPullParser, "valueType", 7, 4); if (TypedArrayUtils.hasAttribute(xmlPullParser, "valueFrom") && TypedArrayUtils.hasAttribute(xmlPullParser, "valueTo")) { if (namedInt3 == 4) { namedInt3 = inferValueTypeFromValues(typedArray, 5, 6); } PropertyValuesHolder pvh = getPVH(typedArray, namedInt3, 5, 6, ""); if (pvh != null) { valueAnimator.setValues(pvh); } } valueAnimator.setDuration(namedInt); valueAnimator.setStartDelay(namedInt2); valueAnimator.setRepeatCount(TypedArrayUtils.getNamedInt(typedArray, xmlPullParser, "repeatCount", 3, 0)); valueAnimator.setRepeatMode(TypedArrayUtils.getNamedInt(typedArray, xmlPullParser, "repeatMode", 4, 1)); if (typedArray2 != null) { setupObjectAnimator(valueAnimator, typedArray2, namedInt3, f, xmlPullParser); } } private static void setupObjectAnimator(ValueAnimator valueAnimator, TypedArray typedArray, int i, float f, XmlPullParser xmlPullParser) { ObjectAnimator objectAnimator = (ObjectAnimator) valueAnimator; String namedString = TypedArrayUtils.getNamedString(typedArray, xmlPullParser, "pathData", 1); if (namedString != null) { String namedString2 = TypedArrayUtils.getNamedString(typedArray, xmlPullParser, "propertyXName", 2); String namedString3 = TypedArrayUtils.getNamedString(typedArray, xmlPullParser, "propertyYName", 3); if (i != 2) { } if (namedString2 == null && namedString3 == null) { throw new InflateException(typedArray.getPositionDescription() + " propertyXName or propertyYName is needed for PathData"); } setupPathMotion(PathParser.createPathFromPathData(namedString), objectAnimator, f * 0.5f, namedString2, namedString3); return; } objectAnimator.setPropertyName(TypedArrayUtils.getNamedString(typedArray, xmlPullParser, "propertyName", 0)); } private static void setupPathMotion(Path path, ObjectAnimator objectAnimator, float f, String str, String str2) { PathMeasure pathMeasure = new PathMeasure(path, false); ArrayList arrayList = new ArrayList(); float f2 = 0.0f; arrayList.add(Float.valueOf(0.0f)); float f3 = 0.0f; do { f3 += pathMeasure.getLength(); arrayList.add(Float.valueOf(f3)); } while (pathMeasure.nextContour()); PathMeasure pathMeasure2 = new PathMeasure(path, false); int min = Math.min(100, ((int) (f3 / f)) + 1); float[] fArr = new float[min]; float[] fArr2 = new float[min]; float[] fArr3 = new float[2]; float f4 = f3 / (min - 1); int i = 0; int i2 = 0; while (true) { if (i >= min) { break; } pathMeasure2.getPosTan(f2 - ((Float) arrayList.get(i2)).floatValue(), fArr3, null); fArr[i] = fArr3[0]; fArr2[i] = fArr3[1]; f2 += f4; int i3 = i2 + 1; if (i3 < arrayList.size() && f2 > ((Float) arrayList.get(i3)).floatValue()) { pathMeasure2.nextContour(); i2 = i3; } i++; } PropertyValuesHolder ofFloat = str != null ? PropertyValuesHolder.ofFloat(str, fArr) : null; PropertyValuesHolder ofFloat2 = str2 != null ? PropertyValuesHolder.ofFloat(str2, fArr2) : null; if (ofFloat == null) { objectAnimator.setValues(ofFloat2); } else if (ofFloat2 == null) { objectAnimator.setValues(ofFloat); } else { objectAnimator.setValues(ofFloat, ofFloat2); } } private static Animator createAnimatorFromXml(Context context, Resources resources, Resources.Theme theme, XmlPullParser xmlPullParser, float f) throws XmlPullParserException, IOException { return createAnimatorFromXml(context, resources, theme, xmlPullParser, Xml.asAttributeSet(xmlPullParser), null, 0, f); } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Removed duplicated region for block: B:33:0x00b8 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static android.animation.Animator createAnimatorFromXml(android.content.Context r18, android.content.res.Resources r19, android.content.res.Resources.Theme r20, org.xmlpull.v1.XmlPullParser r21, android.util.AttributeSet r22, android.animation.AnimatorSet r23, int r24, float r25) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException { /* Method dump skipped, instructions count: 263 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: androidx.vectordrawable.graphics.drawable.AnimatorInflaterCompat.createAnimatorFromXml(android.content.Context, android.content.res.Resources, android.content.res.Resources$Theme, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.animation.AnimatorSet, int, float):android.animation.Animator"); } private static PropertyValuesHolder[] loadValues(Context context, Resources resources, Resources.Theme theme, XmlPullParser xmlPullParser, AttributeSet attributeSet) throws XmlPullParserException, IOException { int i; PropertyValuesHolder[] propertyValuesHolderArr = null; ArrayList arrayList = null; while (true) { int eventType = xmlPullParser.getEventType(); if (eventType == 3 || eventType == 1) { break; } if (eventType != 2) { xmlPullParser.next(); } else { if (xmlPullParser.getName().equals("propertyValuesHolder")) { TypedArray obtainAttributes = TypedArrayUtils.obtainAttributes(resources, theme, attributeSet, AndroidResources.STYLEABLE_PROPERTY_VALUES_HOLDER); String namedString = TypedArrayUtils.getNamedString(obtainAttributes, xmlPullParser, "propertyName", 3); int namedInt = TypedArrayUtils.getNamedInt(obtainAttributes, xmlPullParser, "valueType", 2, 4); PropertyValuesHolder loadPvh = loadPvh(context, resources, theme, xmlPullParser, namedString, namedInt); if (loadPvh == null) { loadPvh = getPVH(obtainAttributes, namedInt, 0, 1, namedString); } if (loadPvh != null) { if (arrayList == null) { arrayList = new ArrayList(); } arrayList.add(loadPvh); } obtainAttributes.recycle(); } xmlPullParser.next(); } } if (arrayList != null) { int size = arrayList.size(); propertyValuesHolderArr = new PropertyValuesHolder[size]; for (i = 0; i < size; i++) { propertyValuesHolderArr[i] = (PropertyValuesHolder) arrayList.get(i); } } return propertyValuesHolderArr; } private static int inferValueTypeOfKeyframe(Resources resources, Resources.Theme theme, AttributeSet attributeSet, XmlPullParser xmlPullParser) { TypedArray obtainAttributes = TypedArrayUtils.obtainAttributes(resources, theme, attributeSet, AndroidResources.STYLEABLE_KEYFRAME); int i = 0; TypedValue peekNamedValue = TypedArrayUtils.peekNamedValue(obtainAttributes, xmlPullParser, "value", 0); if (peekNamedValue != null && isColorType(peekNamedValue.type)) { i = 3; } obtainAttributes.recycle(); return i; } private static int inferValueTypeFromValues(TypedArray typedArray, int i, int i2) { TypedValue peekValue = typedArray.peekValue(i); boolean z = peekValue != null; int i3 = z ? peekValue.type : 0; TypedValue peekValue2 = typedArray.peekValue(i2); boolean z2 = peekValue2 != null; return ((z && isColorType(i3)) || (z2 && isColorType(z2 ? peekValue2.type : 0))) ? 3 : 0; } private static void dumpKeyframes(Object[] objArr, String str) { if (objArr == null || objArr.length == 0) { return; } int length = objArr.length; for (int i = 0; i < length; i++) { Keyframe keyframe = (Keyframe) objArr[i]; StringBuilder sb = new StringBuilder(); sb.append("Keyframe "); sb.append(i); sb.append(": fraction "); Object obj = "null"; sb.append(keyframe.getFraction() < 0.0f ? "null" : Float.valueOf(keyframe.getFraction())); sb.append(", , value : "); if (keyframe.hasValue()) { obj = keyframe.getValue(); } sb.append(obj); } } private static PropertyValuesHolder loadPvh(Context context, Resources resources, Resources.Theme theme, XmlPullParser xmlPullParser, String str, int i) throws XmlPullParserException, IOException { int size; PropertyValuesHolder propertyValuesHolder = null; ArrayList arrayList = null; while (true) { int next = xmlPullParser.next(); if (next == 3 || next == 1) { break; } if (xmlPullParser.getName().equals("keyframe")) { if (i == 4) { i = inferValueTypeOfKeyframe(resources, theme, Xml.asAttributeSet(xmlPullParser), xmlPullParser); } Keyframe loadKeyframe = loadKeyframe(context, resources, theme, Xml.asAttributeSet(xmlPullParser), i, xmlPullParser); if (loadKeyframe != null) { if (arrayList == null) { arrayList = new ArrayList(); } arrayList.add(loadKeyframe); } xmlPullParser.next(); } } if (arrayList != null && (size = arrayList.size()) > 0) { Keyframe keyframe = (Keyframe) arrayList.get(0); Keyframe keyframe2 = (Keyframe) arrayList.get(size - 1); float fraction = keyframe2.getFraction(); if (fraction < 1.0f) { if (fraction < 0.0f) { keyframe2.setFraction(1.0f); } else { arrayList.add(arrayList.size(), createNewKeyframe(keyframe2, 1.0f)); size++; } } float fraction2 = keyframe.getFraction(); if (fraction2 != 0.0f) { if (fraction2 < 0.0f) { keyframe.setFraction(0.0f); } else { arrayList.add(0, createNewKeyframe(keyframe, 0.0f)); size++; } } Keyframe[] keyframeArr = new Keyframe[size]; arrayList.toArray(keyframeArr); for (int i2 = 0; i2 < size; i2++) { Keyframe keyframe3 = keyframeArr[i2]; if (keyframe3.getFraction() < 0.0f) { if (i2 == 0) { keyframe3.setFraction(0.0f); } else { int i3 = size - 1; if (i2 == i3) { keyframe3.setFraction(1.0f); } else { int i4 = i2; for (int i5 = i2 + 1; i5 < i3 && keyframeArr[i5].getFraction() < 0.0f; i5++) { i4 = i5; } distributeKeyframes(keyframeArr, keyframeArr[i4 + 1].getFraction() - keyframeArr[i2 - 1].getFraction(), i2, i4); } } } } propertyValuesHolder = PropertyValuesHolder.ofKeyframe(str, keyframeArr); if (i == 3) { propertyValuesHolder.setEvaluator(ArgbEvaluator.getInstance()); } } return propertyValuesHolder; } private static Keyframe createNewKeyframe(Keyframe keyframe, float f) { if (keyframe.getType() == Float.TYPE) { return Keyframe.ofFloat(f); } if (keyframe.getType() == Integer.TYPE) { return Keyframe.ofInt(f); } return Keyframe.ofObject(f); } private static void distributeKeyframes(Keyframe[] keyframeArr, float f, int i, int i2) { float f2 = f / ((i2 - i) + 2); while (i <= i2) { keyframeArr[i].setFraction(keyframeArr[i - 1].getFraction() + f2); i++; } } private static Keyframe loadKeyframe(Context context, Resources resources, Resources.Theme theme, AttributeSet attributeSet, int i, XmlPullParser xmlPullParser) throws XmlPullParserException, IOException { Keyframe ofInt; TypedArray obtainAttributes = TypedArrayUtils.obtainAttributes(resources, theme, attributeSet, AndroidResources.STYLEABLE_KEYFRAME); float namedFloat = TypedArrayUtils.getNamedFloat(obtainAttributes, xmlPullParser, "fraction", 3, -1.0f); TypedValue peekNamedValue = TypedArrayUtils.peekNamedValue(obtainAttributes, xmlPullParser, "value", 0); boolean z = peekNamedValue != null; if (i == 4) { i = (z && isColorType(peekNamedValue.type)) ? 3 : 0; } if (z) { if (i == 0) { ofInt = Keyframe.ofFloat(namedFloat, TypedArrayUtils.getNamedFloat(obtainAttributes, xmlPullParser, "value", 0, 0.0f)); } else { ofInt = (i == 1 || i == 3) ? Keyframe.ofInt(namedFloat, TypedArrayUtils.getNamedInt(obtainAttributes, xmlPullParser, "value", 0, 0)) : null; } } else if (i == 0) { ofInt = Keyframe.ofFloat(namedFloat); } else { ofInt = Keyframe.ofInt(namedFloat); } int namedResourceId = TypedArrayUtils.getNamedResourceId(obtainAttributes, xmlPullParser, "interpolator", 1, 0); if (namedResourceId > 0) { ofInt.setInterpolator(AnimationUtilsCompat.loadInterpolator(context, namedResourceId)); } obtainAttributes.recycle(); return ofInt; } private static ObjectAnimator loadObjectAnimator(Context context, Resources resources, Resources.Theme theme, AttributeSet attributeSet, float f, XmlPullParser xmlPullParser) throws Resources.NotFoundException { ObjectAnimator objectAnimator = new ObjectAnimator(); loadAnimator(context, resources, theme, attributeSet, objectAnimator, f, xmlPullParser); return objectAnimator; } private static ValueAnimator loadAnimator(Context context, Resources resources, Resources.Theme theme, AttributeSet attributeSet, ValueAnimator valueAnimator, float f, XmlPullParser xmlPullParser) throws Resources.NotFoundException { TypedArray obtainAttributes = TypedArrayUtils.obtainAttributes(resources, theme, attributeSet, AndroidResources.STYLEABLE_ANIMATOR); TypedArray obtainAttributes2 = TypedArrayUtils.obtainAttributes(resources, theme, attributeSet, AndroidResources.STYLEABLE_PROPERTY_ANIMATOR); if (valueAnimator == null) { valueAnimator = new ValueAnimator(); } parseAnimatorFromTypeArray(valueAnimator, obtainAttributes, obtainAttributes2, f, xmlPullParser); int namedResourceId = TypedArrayUtils.getNamedResourceId(obtainAttributes, xmlPullParser, "interpolator", 0, 0); if (namedResourceId > 0) { valueAnimator.setInterpolator(AnimationUtilsCompat.loadInterpolator(context, namedResourceId)); } obtainAttributes.recycle(); if (obtainAttributes2 != null) { obtainAttributes2.recycle(); } return valueAnimator; } private AnimatorInflaterCompat() { } }