package androidx.constraintlayout.motion.widget; import android.view.View; import androidx.annotation.NonNull; import androidx.constraintlayout.motion.utils.Easing; import androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure; import androidx.constraintlayout.widget.ConstraintAttribute; import androidx.constraintlayout.widget.ConstraintSet; import com.discord.models.domain.ModelAuditLogEntry; import com.google.android.material.shadow.ShadowDrawableWrapper; import java.util.Arrays; import java.util.LinkedHashMap; public class MotionPaths implements Comparable { public static final int CARTESIAN = 2; public static final boolean DEBUG = false; public static final int OFF_HEIGHT = 4; public static final int OFF_PATH_ROTATE = 5; public static final int OFF_POSITION = 0; public static final int OFF_WIDTH = 3; public static final int OFF_X = 1; public static final int OFF_Y = 2; public static final boolean OLD_WAY = false; public static final int PERPENDICULAR = 1; public static final int SCREEN = 3; public static final String TAG = "MotionPaths"; public static String[] names = {ModelAuditLogEntry.CHANGE_KEY_POSITION, "x", "y", "width", "height", "pathRotate"}; public LinkedHashMap attributes; public float height; public int mDrawPath; public Easing mKeyFrameEasing; public int mMode; public int mPathMotionArc; public float mPathRotate; public float mProgress; public double[] mTempDelta; public double[] mTempValue; public float position; public float time; public float width; /* renamed from: x reason: collision with root package name */ public float f21x; /* renamed from: y reason: collision with root package name */ public float f22y; public MotionPaths() { this.mDrawPath = 0; this.mPathRotate = Float.NaN; this.mProgress = Float.NaN; this.mPathMotionArc = Key.UNSET; this.attributes = new LinkedHashMap<>(); this.mMode = 0; this.mTempValue = new double[18]; this.mTempDelta = new double[18]; } public MotionPaths(int i, int i2, KeyPosition keyPosition, MotionPaths motionPaths, MotionPaths motionPaths2) { this.mDrawPath = 0; this.mPathRotate = Float.NaN; this.mProgress = Float.NaN; this.mPathMotionArc = Key.UNSET; this.attributes = new LinkedHashMap<>(); this.mMode = 0; this.mTempValue = new double[18]; this.mTempDelta = new double[18]; int i3 = keyPosition.mPositionType; if (i3 == 1) { initPath(keyPosition, motionPaths, motionPaths2); } else if (i3 != 2) { initCartesian(keyPosition, motionPaths, motionPaths2); } else { initScreen(i, i2, keyPosition, motionPaths, motionPaths2); } } private boolean diff(float f, float f2) { return (Float.isNaN(f) || Float.isNaN(f2)) ? Float.isNaN(f) != Float.isNaN(f2) : Math.abs(f - f2) > 1.0E-6f; } private static final float xRotate(float f, float f2, float f3, float f4, float f5, float f6) { return (((f5 - f3) * f2) - ((f6 - f4) * f)) + f3; } private static final float yRotate(float f, float f2, float f3, float f4, float f5, float f6) { return ((f6 - f4) * f2) + ((f5 - f3) * f) + f4; } public void applyParameters(ConstraintSet.Constraint constraint) { this.mKeyFrameEasing = Easing.getInterpolator(constraint.motion.mTransitionEasing); ConstraintSet.Motion motion = constraint.motion; this.mPathMotionArc = motion.mPathMotionArc; this.mPathRotate = motion.mPathRotate; this.mDrawPath = motion.mDrawPath; this.mProgress = constraint.propertySet.mProgress; for (String str : constraint.mCustomConstraints.keySet()) { ConstraintAttribute constraintAttribute = constraint.mCustomConstraints.get(str); if (constraintAttribute.getType() != ConstraintAttribute.AttributeType.STRING_TYPE) { this.attributes.put(str, constraintAttribute); } } } public int compareTo(@NonNull MotionPaths motionPaths) { return Float.compare(this.position, motionPaths.position); } public void different(MotionPaths motionPaths, boolean[] zArr, String[] strArr, boolean z2) { zArr[0] = zArr[0] | diff(this.position, motionPaths.position); zArr[1] = zArr[1] | diff(this.f21x, motionPaths.f21x) | z2; zArr[2] = z2 | diff(this.f22y, motionPaths.f22y) | zArr[2]; zArr[3] = zArr[3] | diff(this.width, motionPaths.width); zArr[4] = diff(this.height, motionPaths.height) | zArr[4]; } public void fillStandard(double[] dArr, int[] iArr) { float[] fArr = {this.position, this.f21x, this.f22y, this.width, this.height, this.mPathRotate}; int i = 0; for (int i2 = 0; i2 < iArr.length; i2++) { if (iArr[i2] < 6) { dArr[i] = (double) fArr[iArr[i2]]; i++; } } } public void getBounds(int[] iArr, double[] dArr, float[] fArr, int i) { float f = this.width; float f2 = this.height; for (int i2 = 0; i2 < iArr.length; i2++) { float f3 = (float) dArr[i2]; int i3 = iArr[i2]; if (i3 == 3) { f = f3; } else if (i3 == 4) { f2 = f3; } } fArr[i] = f; fArr[i + 1] = f2; } public void getCenter(int[] iArr, double[] dArr, float[] fArr, int i) { float f = this.f21x; float f2 = this.f22y; float f3 = this.width; float f4 = this.height; for (int i2 = 0; i2 < iArr.length; i2++) { float f5 = (float) dArr[i2]; int i3 = iArr[i2]; if (i3 == 1) { f = f5; } else if (i3 == 2) { f2 = f5; } else if (i3 == 3) { f3 = f5; } else if (i3 == 4) { f4 = f5; } } fArr[i] = (f3 / 2.0f) + f + 0.0f; fArr[i + 1] = (f4 / 2.0f) + f2 + 0.0f; } public int getCustomData(String str, double[] dArr, int i) { ConstraintAttribute constraintAttribute = this.attributes.get(str); if (constraintAttribute.noOfInterpValues() == 1) { dArr[i] = (double) constraintAttribute.getValueToInterpolate(); return 1; } int noOfInterpValues = constraintAttribute.noOfInterpValues(); float[] fArr = new float[noOfInterpValues]; constraintAttribute.getValuesToInterpolate(fArr); int i2 = 0; while (i2 < noOfInterpValues) { dArr[i] = (double) fArr[i2]; i2++; i++; } return noOfInterpValues; } public int getCustomDataCount(String str) { return this.attributes.get(str).noOfInterpValues(); } public void getRect(int[] iArr, double[] dArr, float[] fArr, int i) { float f = this.f21x; float f2 = this.f22y; float f3 = this.width; float f4 = this.height; for (int i2 = 0; i2 < iArr.length; i2++) { float f5 = (float) dArr[i2]; int i3 = iArr[i2]; if (i3 == 1) { f = f5; } else if (i3 == 2) { f2 = f5; } else if (i3 == 3) { f3 = f5; } else if (i3 == 4) { f4 = f5; } } float f6 = f3 + f; float f7 = f4 + f2; Float.isNaN(Float.NaN); Float.isNaN(Float.NaN); int i4 = i + 1; fArr[i] = f + 0.0f; int i5 = i4 + 1; fArr[i4] = f2 + 0.0f; int i6 = i5 + 1; fArr[i5] = f6 + 0.0f; int i7 = i6 + 1; fArr[i6] = f2 + 0.0f; int i8 = i7 + 1; fArr[i7] = f6 + 0.0f; int i9 = i8 + 1; fArr[i8] = f7 + 0.0f; fArr[i9] = f + 0.0f; fArr[i9 + 1] = f7 + 0.0f; } public boolean hasCustomData(String str) { return this.attributes.containsKey(str); } public void initCartesian(KeyPosition keyPosition, MotionPaths motionPaths, MotionPaths motionPaths2) { float f = ((float) keyPosition.mFramePosition) / 100.0f; this.time = f; this.mDrawPath = keyPosition.mDrawPath; float f2 = Float.isNaN(keyPosition.mPercentWidth) ? f : keyPosition.mPercentWidth; float f3 = Float.isNaN(keyPosition.mPercentHeight) ? f : keyPosition.mPercentHeight; float f4 = motionPaths2.width; float f5 = motionPaths.width; float f6 = f4 - f5; float f7 = motionPaths2.height; float f8 = motionPaths.height; float f9 = f7 - f8; this.position = this.time; float f10 = motionPaths.f21x; float f11 = motionPaths.f22y; float f12 = ((f4 / 2.0f) + motionPaths2.f21x) - ((f5 / 2.0f) + f10); float f13 = ((f7 / 2.0f) + motionPaths2.f22y) - ((f8 / 2.0f) + f11); float f14 = f6 * f2; float f15 = f14 / 2.0f; this.f21x = (float) ((int) (((f12 * f) + f10) - f15)); float f16 = (f13 * f) + f11; float f17 = f9 * f3; float f18 = f17 / 2.0f; this.f22y = (float) ((int) (f16 - f18)); this.width = (float) ((int) (f5 + f14)); this.height = (float) ((int) (f8 + f17)); float f19 = Float.isNaN(keyPosition.mPercentX) ? f : keyPosition.mPercentX; float f20 = 0.0f; float f21 = Float.isNaN(keyPosition.mAltPercentY) ? 0.0f : keyPosition.mAltPercentY; if (!Float.isNaN(keyPosition.mPercentY)) { f = keyPosition.mPercentY; } if (!Float.isNaN(keyPosition.mAltPercentX)) { f20 = keyPosition.mAltPercentX; } this.mMode = 2; this.f21x = (float) ((int) (((f20 * f13) + ((f19 * f12) + motionPaths.f21x)) - f15)); this.f22y = (float) ((int) (((f13 * f) + ((f12 * f21) + motionPaths.f22y)) - f18)); this.mKeyFrameEasing = Easing.getInterpolator(keyPosition.mTransitionEasing); this.mPathMotionArc = keyPosition.mPathMotionArc; } public void initPath(KeyPosition keyPosition, MotionPaths motionPaths, MotionPaths motionPaths2) { float f = ((float) keyPosition.mFramePosition) / 100.0f; this.time = f; this.mDrawPath = keyPosition.mDrawPath; float f2 = Float.isNaN(keyPosition.mPercentWidth) ? f : keyPosition.mPercentWidth; float f3 = Float.isNaN(keyPosition.mPercentHeight) ? f : keyPosition.mPercentHeight; float f4 = motionPaths2.width - motionPaths.width; float f5 = motionPaths2.height - motionPaths.height; this.position = this.time; if (!Float.isNaN(keyPosition.mPercentX)) { f = keyPosition.mPercentX; } float f6 = motionPaths.f21x; float f7 = motionPaths.width; float f8 = motionPaths.f22y; float f9 = motionPaths.height; float f10 = ((motionPaths2.width / 2.0f) + motionPaths2.f21x) - ((f7 / 2.0f) + f6); float f11 = ((motionPaths2.height / 2.0f) + motionPaths2.f22y) - ((f9 / 2.0f) + f8); float f12 = f10 * f; float f13 = f4 * f2; float f14 = f13 / 2.0f; this.f21x = (float) ((int) ((f6 + f12) - f14)); float f15 = f * f11; float f16 = f5 * f3; float f17 = f16 / 2.0f; this.f22y = (float) ((int) ((f8 + f15) - f17)); this.width = (float) ((int) (f7 + f13)); this.height = (float) ((int) (f9 + f16)); float f18 = Float.isNaN(keyPosition.mPercentY) ? 0.0f : keyPosition.mPercentY; this.mMode = 1; float f19 = (float) ((int) ((motionPaths.f21x + f12) - f14)); this.f21x = f19; float f20 = (float) ((int) ((motionPaths.f22y + f15) - f17)); this.f22y = f20; this.f21x = f19 + ((-f11) * f18); this.f22y = f20 + (f10 * f18); this.mKeyFrameEasing = Easing.getInterpolator(keyPosition.mTransitionEasing); this.mPathMotionArc = keyPosition.mPathMotionArc; } public void initScreen(int i, int i2, KeyPosition keyPosition, MotionPaths motionPaths, MotionPaths motionPaths2) { float f = ((float) keyPosition.mFramePosition) / 100.0f; this.time = f; this.mDrawPath = keyPosition.mDrawPath; float f2 = Float.isNaN(keyPosition.mPercentWidth) ? f : keyPosition.mPercentWidth; float f3 = Float.isNaN(keyPosition.mPercentHeight) ? f : keyPosition.mPercentHeight; float f4 = motionPaths2.width; float f5 = motionPaths.width; float f6 = f4 - f5; float f7 = motionPaths2.height; float f8 = motionPaths.height; float f9 = f7 - f8; this.position = this.time; float f10 = motionPaths.f21x; float f11 = motionPaths.f22y; float f12 = (f4 / 2.0f) + motionPaths2.f21x; float f13 = (f7 / 2.0f) + motionPaths2.f22y; float f14 = f6 * f2; this.f21x = (float) ((int) ((((f12 - ((f5 / 2.0f) + f10)) * f) + f10) - (f14 / 2.0f))); float f15 = f9 * f3; this.f22y = (float) ((int) ((((f13 - ((f8 / 2.0f) + f11)) * f) + f11) - (f15 / 2.0f))); this.width = (float) ((int) (f5 + f14)); this.height = (float) ((int) (f8 + f15)); this.mMode = 3; if (!Float.isNaN(keyPosition.mPercentX)) { this.f21x = (float) ((int) (keyPosition.mPercentX * ((float) ((int) (((float) i) - this.width))))); } if (!Float.isNaN(keyPosition.mPercentY)) { this.f22y = (float) ((int) (keyPosition.mPercentY * ((float) ((int) (((float) i2) - this.height))))); } this.mKeyFrameEasing = Easing.getInterpolator(keyPosition.mTransitionEasing); this.mPathMotionArc = keyPosition.mPathMotionArc; } public void setBounds(float f, float f2, float f3, float f4) { this.f21x = f; this.f22y = f2; this.width = f3; this.height = f4; } public void setDpDt(float f, float f2, float[] fArr, int[] iArr, double[] dArr, double[] dArr2) { float f3 = 0.0f; float f4 = 0.0f; float f5 = 0.0f; float f6 = 0.0f; for (int i = 0; i < iArr.length; i++) { float f7 = (float) dArr[i]; double d = dArr2[i]; int i2 = iArr[i]; if (i2 == 1) { f3 = f7; } else if (i2 == 2) { f5 = f7; } else if (i2 == 3) { f4 = f7; } else if (i2 == 4) { f6 = f7; } } float f8 = f3 - ((0.0f * f4) / 2.0f); float f9 = f5 - ((0.0f * f6) / 2.0f); fArr[0] = (((f4 * 1.0f) + f8) * f) + ((1.0f - f) * f8) + 0.0f; fArr[1] = (((f6 * 1.0f) + f9) * f2) + ((1.0f - f2) * f9) + 0.0f; } public void setView(View view, int[] iArr, double[] dArr, double[] dArr2, double[] dArr3) { float f; float f2 = this.f21x; float f3 = this.f22y; float f4 = this.width; float f5 = this.height; if (iArr.length != 0 && this.mTempValue.length <= iArr[iArr.length - 1]) { int i = iArr[iArr.length - 1] + 1; this.mTempValue = new double[i]; this.mTempDelta = new double[i]; } Arrays.fill(this.mTempValue, Double.NaN); for (int i2 = 0; i2 < iArr.length; i2++) { this.mTempValue[iArr[i2]] = dArr[i2]; this.mTempDelta[iArr[i2]] = dArr2[i2]; } int i3 = 0; float f6 = Float.NaN; float f7 = 0.0f; float f8 = 0.0f; float f9 = 0.0f; float f10 = 0.0f; while (true) { double[] dArr4 = this.mTempValue; if (i3 >= dArr4.length) { break; } boolean isNaN = Double.isNaN(dArr4[i3]); double d = ShadowDrawableWrapper.COS_45; if (!isNaN || !(dArr3 == null || dArr3[i3] == ShadowDrawableWrapper.COS_45)) { if (dArr3 != null) { d = dArr3[i3]; } if (!Double.isNaN(this.mTempValue[i3])) { d = this.mTempValue[i3] + d; } f = f2; float f11 = (float) d; float f12 = (float) this.mTempDelta[i3]; if (i3 == 1) { f7 = f12; f2 = f11; } else if (i3 == 2) { f3 = f11; f9 = f12; } else if (i3 == 3) { f4 = f11; f8 = f12; } else if (i3 == 4) { f5 = f11; f10 = f12; } else if (i3 == 5) { f2 = f; f6 = f11; } i3++; } else { f = f2; } f2 = f; i3++; } if (!Float.isNaN(f6)) { float f13 = Float.NaN; if (Float.isNaN(Float.NaN)) { f13 = 0.0f; } view.setRotation((float) (Math.toDegrees(Math.atan2((double) ((f10 / 2.0f) + f9), (double) ((f8 / 2.0f) + f7))) + ((double) f6) + ((double) f13))); } else if (!Float.isNaN(Float.NaN)) { view.setRotation(Float.NaN); } float f14 = f2 + 0.5f; int i4 = (int) f14; float f15 = f3 + 0.5f; int i5 = (int) f15; int i6 = (int) (f14 + f4); int i7 = (int) (f15 + f5); int i8 = i6 - i4; int i9 = i7 - i5; if ((i8 == view.getMeasuredWidth() && i9 == view.getMeasuredHeight()) ? false : true) { view.measure(View.MeasureSpec.makeMeasureSpec(i8, BasicMeasure.EXACTLY), View.MeasureSpec.makeMeasureSpec(i9, BasicMeasure.EXACTLY)); } view.layout(i4, i5, i6, i7); } }