package androidx.constraintlayout.widget; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.Log; import android.util.TypedValue; import android.util.Xml; import android.view.View; import androidx.constraintlayout.motion.widget.Debug; import c.d.b.a.a; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import org.xmlpull.v1.XmlPullParser; public class ConstraintAttribute { private static final String TAG = "TransitionLayout"; public boolean mBooleanValue; private int mColorValue; private float mFloatValue; private int mIntegerValue; public String mName; private String mStringValue; private AttributeType mType; /* renamed from: androidx.constraintlayout.widget.ConstraintAttribute$1 reason: invalid class name */ public static /* synthetic */ class AnonymousClass1 { public static final /* synthetic */ int[] $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType; static { AttributeType.values(); int[] iArr = new int[7]; $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType = iArr; try { iArr[AttributeType.COLOR_TYPE.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[AttributeType.COLOR_DRAWABLE_TYPE.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[AttributeType.INT_TYPE.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[AttributeType.FLOAT_TYPE.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } try { $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[AttributeType.STRING_TYPE.ordinal()] = 5; } catch (NoSuchFieldError unused5) { } try { $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[AttributeType.BOOLEAN_TYPE.ordinal()] = 6; } catch (NoSuchFieldError unused6) { } try { $SwitchMap$androidx$constraintlayout$widget$ConstraintAttribute$AttributeType[AttributeType.DIMENSION_TYPE.ordinal()] = 7; } catch (NoSuchFieldError unused7) { } } } public enum AttributeType { INT_TYPE, FLOAT_TYPE, COLOR_TYPE, COLOR_DRAWABLE_TYPE, STRING_TYPE, BOOLEAN_TYPE, DIMENSION_TYPE } public ConstraintAttribute(ConstraintAttribute constraintAttribute, Object obj) { this.mName = constraintAttribute.mName; this.mType = constraintAttribute.mType; setValue(obj); } public ConstraintAttribute(String str, AttributeType attributeType) { this.mName = str; this.mType = attributeType; } public ConstraintAttribute(String str, AttributeType attributeType, Object obj) { this.mName = str; this.mType = attributeType; setValue(obj); } private static int clamp(int i) { int i2 = (i & (~(i >> 31))) - 255; return (i2 & (i2 >> 31)) + 255; } public static HashMap extractAttributes(HashMap hashMap, View view) { HashMap hashMap2 = new HashMap<>(); Class cls = view.getClass(); for (String str : hashMap.keySet()) { ConstraintAttribute constraintAttribute = hashMap.get(str); try { if (str.equals("BackgroundColor")) { hashMap2.put(str, new ConstraintAttribute(constraintAttribute, Integer.valueOf(((ColorDrawable) view.getBackground()).getColor()))); } else { hashMap2.put(str, new ConstraintAttribute(constraintAttribute, cls.getMethod("getMap" + str, new Class[0]).invoke(view, new Object[0]))); } } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e2) { e2.printStackTrace(); } catch (InvocationTargetException e3) { e3.printStackTrace(); } } return hashMap2; } public static void parse(Context context, XmlPullParser xmlPullParser, HashMap hashMap) { AttributeType attributeType; Object string; TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R.styleable.CustomAttribute); int indexCount = obtainStyledAttributes.getIndexCount(); String str = null; Object obj = null; AttributeType attributeType2 = null; for (int i = 0; i < indexCount; i++) { int index = obtainStyledAttributes.getIndex(i); if (index == R.styleable.CustomAttribute_attributeName) { str = obtainStyledAttributes.getString(index); if (str != null && str.length() > 0) { str = Character.toUpperCase(str.charAt(0)) + str.substring(1); } } else if (index == R.styleable.CustomAttribute_customBoolean) { obj = Boolean.valueOf(obtainStyledAttributes.getBoolean(index, false)); attributeType2 = AttributeType.BOOLEAN_TYPE; } else { if (index == R.styleable.CustomAttribute_customColorValue) { attributeType = AttributeType.COLOR_TYPE; string = Integer.valueOf(obtainStyledAttributes.getColor(index, 0)); } else if (index == R.styleable.CustomAttribute_customColorDrawableValue) { attributeType = AttributeType.COLOR_DRAWABLE_TYPE; string = Integer.valueOf(obtainStyledAttributes.getColor(index, 0)); } else if (index == R.styleable.CustomAttribute_customPixelDimension) { attributeType = AttributeType.DIMENSION_TYPE; string = Float.valueOf(TypedValue.applyDimension(1, obtainStyledAttributes.getDimension(index, 0.0f), context.getResources().getDisplayMetrics())); } else if (index == R.styleable.CustomAttribute_customDimension) { attributeType = AttributeType.DIMENSION_TYPE; string = Float.valueOf(obtainStyledAttributes.getDimension(index, 0.0f)); } else if (index == R.styleable.CustomAttribute_customFloatValue) { attributeType = AttributeType.FLOAT_TYPE; string = Float.valueOf(obtainStyledAttributes.getFloat(index, Float.NaN)); } else if (index == R.styleable.CustomAttribute_customIntegerValue) { attributeType = AttributeType.INT_TYPE; string = Integer.valueOf(obtainStyledAttributes.getInteger(index, -1)); } else if (index == R.styleable.CustomAttribute_customStringValue) { attributeType = AttributeType.STRING_TYPE; string = obtainStyledAttributes.getString(index); } attributeType2 = attributeType; obj = string; } } if (!(str == null || obj == null)) { hashMap.put(str, new ConstraintAttribute(str, attributeType2, obj)); } obtainStyledAttributes.recycle(); } public static void setAttributes(View view, HashMap hashMap) { Class cls = view.getClass(); for (String str : hashMap.keySet()) { ConstraintAttribute constraintAttribute = hashMap.get(str); String t = a.t("set", str); try { switch (constraintAttribute.mType.ordinal()) { case 0: cls.getMethod(t, Integer.TYPE).invoke(view, Integer.valueOf(constraintAttribute.mIntegerValue)); continue; case 1: cls.getMethod(t, Float.TYPE).invoke(view, Float.valueOf(constraintAttribute.mFloatValue)); continue; case 2: cls.getMethod(t, Integer.TYPE).invoke(view, Integer.valueOf(constraintAttribute.mColorValue)); continue; case 3: Method method = cls.getMethod(t, Drawable.class); ColorDrawable colorDrawable = new ColorDrawable(); colorDrawable.setColor(constraintAttribute.mColorValue); method.invoke(view, colorDrawable); continue; case 4: cls.getMethod(t, CharSequence.class).invoke(view, constraintAttribute.mStringValue); continue; case 5: cls.getMethod(t, Boolean.TYPE).invoke(view, Boolean.valueOf(constraintAttribute.mBooleanValue)); continue; case 6: cls.getMethod(t, Float.TYPE).invoke(view, Float.valueOf(constraintAttribute.mFloatValue)); continue; default: continue; } } catch (NoSuchMethodException e) { Log.e("TransitionLayout", e.getMessage()); Log.e("TransitionLayout", " Custom Attribute \"" + str + "\" not found on " + cls.getName()); StringBuilder sb = new StringBuilder(); sb.append(cls.getName()); sb.append(" must have a method "); sb.append(t); Log.e("TransitionLayout", sb.toString()); } catch (IllegalAccessException e2) { StringBuilder Q = a.Q(" Custom Attribute \"", str, "\" not found on "); Q.append(cls.getName()); Log.e("TransitionLayout", Q.toString()); e2.printStackTrace(); } catch (InvocationTargetException e3) { StringBuilder Q2 = a.Q(" Custom Attribute \"", str, "\" not found on "); Q2.append(cls.getName()); Log.e("TransitionLayout", Q2.toString()); e3.printStackTrace(); } } } public boolean diff(ConstraintAttribute constraintAttribute) { AttributeType attributeType; if (constraintAttribute == null || (attributeType = this.mType) != constraintAttribute.mType) { return false; } switch (attributeType.ordinal()) { case 0: return this.mIntegerValue == constraintAttribute.mIntegerValue; case 1: return this.mFloatValue == constraintAttribute.mFloatValue; case 2: case 3: return this.mColorValue == constraintAttribute.mColorValue; case 4: return this.mIntegerValue == constraintAttribute.mIntegerValue; case 5: return this.mBooleanValue == constraintAttribute.mBooleanValue; case 6: return this.mFloatValue == constraintAttribute.mFloatValue; default: return false; } } public AttributeType getType() { return this.mType; } public float getValueToInterpolate() { switch (this.mType.ordinal()) { case 0: return (float) this.mIntegerValue; case 1: return this.mFloatValue; case 2: case 3: throw new RuntimeException("Color does not have a single color to interpolate"); case 4: throw new RuntimeException("Cannot interpolate String"); case 5: return this.mBooleanValue ? 1.0f : 0.0f; case 6: return this.mFloatValue; default: return Float.NaN; } } public void getValuesToInterpolate(float[] fArr) { switch (this.mType.ordinal()) { case 0: fArr[0] = (float) this.mIntegerValue; return; case 1: fArr[0] = this.mFloatValue; return; case 2: case 3: int i = this.mColorValue; float pow = (float) Math.pow((double) (((float) ((i >> 16) & 255)) / 255.0f), 2.2d); float pow2 = (float) Math.pow((double) (((float) ((i >> 8) & 255)) / 255.0f), 2.2d); fArr[0] = pow; fArr[1] = pow2; fArr[2] = (float) Math.pow((double) (((float) (i & 255)) / 255.0f), 2.2d); fArr[3] = ((float) ((i >> 24) & 255)) / 255.0f; return; case 4: throw new RuntimeException("Color does not have a single color to interpolate"); case 5: fArr[0] = this.mBooleanValue ? 1.0f : 0.0f; return; case 6: fArr[0] = this.mFloatValue; return; default: return; } } public int noOfInterpValues() { int ordinal = this.mType.ordinal(); return (ordinal == 2 || ordinal == 3) ? 4 : 1; } public void setColorValue(int i) { this.mColorValue = i; } public void setFloatValue(float f) { this.mFloatValue = f; } public void setIntValue(int i) { this.mIntegerValue = i; } /* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x0068: APUT (r7v38 java.lang.Object[]) (0 ??[int, short, byte, char]) (wrap: java.lang.Boolean : 0x0064: INVOKE (r8v30 java.lang.Boolean) = (r13v12 boolean) type: STATIC call: java.lang.Boolean.valueOf(boolean):java.lang.Boolean) */ public void setInterpolatedValue(View view, float[] fArr) { Class cls = view.getClass(); StringBuilder L = a.L("set"); L.append(this.mName); String sb = L.toString(); try { boolean z2 = true; switch (this.mType.ordinal()) { case 0: cls.getMethod(sb, Integer.TYPE).invoke(view, Integer.valueOf((int) fArr[0])); return; case 1: cls.getMethod(sb, Float.TYPE).invoke(view, Float.valueOf(fArr[0])); return; case 2: cls.getMethod(sb, Integer.TYPE).invoke(view, Integer.valueOf((clamp((int) (((float) Math.pow((double) fArr[0], 0.45454545454545453d)) * 255.0f)) << 16) | (clamp((int) (fArr[3] * 255.0f)) << 24) | (clamp((int) (((float) Math.pow((double) fArr[1], 0.45454545454545453d)) * 255.0f)) << 8) | clamp((int) (((float) Math.pow((double) fArr[2], 0.45454545454545453d)) * 255.0f)))); return; case 3: Method method = cls.getMethod(sb, Drawable.class); int clamp = clamp((int) (((float) Math.pow((double) fArr[0], 0.45454545454545453d)) * 255.0f)); int clamp2 = clamp((int) (((float) Math.pow((double) fArr[1], 0.45454545454545453d)) * 255.0f)); ColorDrawable colorDrawable = new ColorDrawable(); colorDrawable.setColor((clamp << 16) | (clamp((int) (fArr[3] * 255.0f)) << 24) | (clamp2 << 8) | clamp((int) (((float) Math.pow((double) fArr[2], 0.45454545454545453d)) * 255.0f))); method.invoke(view, colorDrawable); return; case 4: throw new RuntimeException("unable to interpolate strings " + this.mName); case 5: Method method2 = cls.getMethod(sb, Boolean.TYPE); Object[] objArr = new Object[1]; if (fArr[0] <= 0.5f) { z2 = false; } objArr[0] = Boolean.valueOf(z2); method2.invoke(view, objArr); return; case 6: cls.getMethod(sb, Float.TYPE).invoke(view, Float.valueOf(fArr[0])); return; default: return; } } catch (NoSuchMethodException e) { StringBuilder Q = a.Q("no method ", sb, "on View \""); Q.append(Debug.getName(view)); Q.append("\""); Log.e("TransitionLayout", Q.toString()); e.printStackTrace(); } catch (IllegalAccessException e2) { StringBuilder Q2 = a.Q("cannot access method ", sb, "on View \""); Q2.append(Debug.getName(view)); Q2.append("\""); Log.e("TransitionLayout", Q2.toString()); e2.printStackTrace(); } catch (InvocationTargetException e3) { e3.printStackTrace(); } } public void setStringValue(String str) { this.mStringValue = str; } public void setValue(Object obj) { switch (this.mType.ordinal()) { case 0: this.mIntegerValue = ((Integer) obj).intValue(); return; case 1: this.mFloatValue = ((Float) obj).floatValue(); return; case 2: case 3: this.mColorValue = ((Integer) obj).intValue(); return; case 4: this.mStringValue = (String) obj; return; case 5: this.mBooleanValue = ((Boolean) obj).booleanValue(); return; case 6: this.mFloatValue = ((Float) obj).floatValue(); return; default: return; } } public void setValue(float[] fArr) { boolean z2 = false; switch (this.mType.ordinal()) { case 0: this.mIntegerValue = (int) fArr[0]; return; case 1: this.mFloatValue = fArr[0]; return; case 2: case 3: int HSVToColor = Color.HSVToColor(fArr); this.mColorValue = HSVToColor; this.mColorValue = (clamp((int) (fArr[3] * 255.0f)) << 24) | (HSVToColor & 16777215); return; case 4: throw new RuntimeException("Color does not have a single color to interpolate"); case 5: if (((double) fArr[0]) > 0.5d) { z2 = true; } this.mBooleanValue = z2; return; case 6: this.mFloatValue = fArr[0]; return; default: return; } } }