discord-jadx/app/src/main/java/androidx/constraintlayout/motion/widget/MotionController.java

1254 lines
51 KiB
Java

package androidx.constraintlayout.motion.widget;
import android.graphics.RectF;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import androidx.constraintlayout.motion.utils.CurveFit;
import androidx.constraintlayout.motion.utils.Easing;
import androidx.constraintlayout.motion.utils.VelocityMatrix;
import androidx.constraintlayout.motion.widget.KeyCycleOscillator;
import androidx.constraintlayout.motion.widget.SplineSet;
import androidx.constraintlayout.motion.widget.TimeCycleSplineSet;
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
import androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure;
import androidx.constraintlayout.widget.ConstraintAttribute;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import b.d.b.a.a;
import com.google.android.material.shadow.ShadowDrawableWrapper;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
/* loaded from: classes.dex */
public class MotionController {
private static final boolean DEBUG = false;
public static final int DRAW_PATH_AS_CONFIGURED = 4;
public static final int DRAW_PATH_BASIC = 1;
public static final int DRAW_PATH_CARTESIAN = 3;
public static final int DRAW_PATH_NONE = 0;
public static final int DRAW_PATH_RECTANGLE = 5;
public static final int DRAW_PATH_RELATIVE = 2;
public static final int DRAW_PATH_SCREEN = 6;
private static final boolean FAVOR_FIXED_SIZE_VIEWS = false;
public static final int HORIZONTAL_PATH_X = 2;
public static final int HORIZONTAL_PATH_Y = 3;
public static final int PATH_PERCENT = 0;
public static final int PATH_PERPENDICULAR = 1;
private static final String TAG = "MotionController";
public static final int VERTICAL_PATH_X = 4;
public static final int VERTICAL_PATH_Y = 5;
public String[] attributeTable;
private CurveFit mArcSpline;
private int[] mAttributeInterpCount;
private String[] mAttributeNames;
private HashMap<String, SplineSet> mAttributesMap;
public String mConstraintTag;
private HashMap<String, KeyCycleOscillator> mCycleMap;
public int mId;
private double[] mInterpolateData;
private int[] mInterpolateVariables;
private double[] mInterpolateVelocity;
private KeyTrigger[] mKeyTriggers;
private CurveFit[] mSpline;
private HashMap<String, TimeCycleSplineSet> mTimeCycleAttributesMap;
public View mView;
private int mCurveFitType = -1;
private MotionPaths mStartMotionPath = new MotionPaths();
private MotionPaths mEndMotionPath = new MotionPaths();
private MotionConstrainedPoint mStartPoint = new MotionConstrainedPoint();
private MotionConstrainedPoint mEndPoint = new MotionConstrainedPoint();
public float mMotionStagger = Float.NaN;
public float mStaggerOffset = 0.0f;
public float mStaggerScale = 1.0f;
private int MAX_DIMENSION = 4;
private float[] mValuesBuff = new float[4];
private ArrayList<MotionPaths> mMotionPaths = new ArrayList<>();
private float[] mVelocity = new float[1];
private ArrayList<Key> mKeyList = new ArrayList<>();
private int mPathMotionArc = Key.UNSET;
public MotionController(View view) {
setView(view);
}
private float getAdjustedPosition(float f, float[] fArr) {
float f2 = 0.0f;
float f3 = 1.0f;
if (fArr != null) {
fArr[0] = 1.0f;
} else {
float f4 = this.mStaggerScale;
if (f4 != 1.0d) {
float f5 = this.mStaggerOffset;
if (f < f5) {
f = 0.0f;
}
if (f > f5 && f < 1.0d) {
f = (f - f5) * f4;
}
}
}
Easing easing = this.mStartMotionPath.mKeyFrameEasing;
float f6 = Float.NaN;
Iterator<MotionPaths> it = this.mMotionPaths.iterator();
while (it.hasNext()) {
MotionPaths next = it.next();
Easing easing2 = next.mKeyFrameEasing;
if (easing2 != null) {
float f7 = next.time;
if (f7 < f) {
easing = easing2;
f2 = f7;
} else if (Float.isNaN(f6)) {
f6 = next.time;
}
}
}
if (easing != null) {
if (!Float.isNaN(f6)) {
f3 = f6;
}
float f8 = f3 - f2;
double d = (f - f2) / f8;
f = (((float) easing.get(d)) * f8) + f2;
if (fArr != null) {
fArr[0] = (float) easing.getDiff(d);
}
}
return f;
}
private float getPreCycleDistance() {
float f;
float[] fArr = new float[2];
float f2 = 1.0f / 99;
double d = ShadowDrawableWrapper.COS_45;
double d2 = 0.0d;
int i = 0;
float f3 = 0.0f;
while (i < 100) {
float f4 = i * f2;
double d3 = f4;
Easing easing = this.mStartMotionPath.mKeyFrameEasing;
float f5 = Float.NaN;
Iterator<MotionPaths> it = this.mMotionPaths.iterator();
float f6 = 0.0f;
while (it.hasNext()) {
MotionPaths next = it.next();
Easing easing2 = next.mKeyFrameEasing;
if (easing2 != null) {
float f7 = next.time;
if (f7 < f4) {
f6 = f7;
easing = easing2;
} else if (Float.isNaN(f5)) {
f5 = next.time;
}
}
f2 = f2;
}
if (easing != null) {
if (Float.isNaN(f5)) {
f5 = 1.0f;
}
d3 = (((float) easing.get((f4 - f6) / f)) * (f5 - f6)) + f6;
}
this.mSpline[0].getPos(d3, this.mInterpolateData);
this.mStartMotionPath.getCenter(this.mInterpolateVariables, this.mInterpolateData, fArr, 0);
if (i > 0) {
f3 = (float) (Math.hypot(d2 - fArr[1], d - fArr[0]) + f3);
}
d = fArr[0];
d2 = fArr[1];
i++;
f2 = f2;
}
return f3;
}
private void insertKey(MotionPaths motionPaths) {
int binarySearch = Collections.binarySearch(this.mMotionPaths, motionPaths);
if (binarySearch == 0) {
StringBuilder S = a.S(" KeyPath positon \"");
S.append(motionPaths.position);
S.append("\" outside of range");
Log.e(TAG, S.toString());
}
this.mMotionPaths.add((-binarySearch) - 1, motionPaths);
}
private void readView(MotionPaths motionPaths) {
motionPaths.setBounds((int) this.mView.getX(), (int) this.mView.getY(), this.mView.getWidth(), this.mView.getHeight());
}
public void addKey(Key key) {
this.mKeyList.add(key);
}
public void addKeys(ArrayList<Key> arrayList) {
this.mKeyList.addAll(arrayList);
}
public void buildBounds(float[] fArr, int i) {
float f;
float f2 = 1.0f / (i - 1);
HashMap<String, SplineSet> hashMap = this.mAttributesMap;
if (hashMap != null) {
hashMap.get(Key.TRANSLATION_X);
}
HashMap<String, SplineSet> hashMap2 = this.mAttributesMap;
if (hashMap2 != null) {
hashMap2.get(Key.TRANSLATION_Y);
}
HashMap<String, KeyCycleOscillator> hashMap3 = this.mCycleMap;
if (hashMap3 != null) {
hashMap3.get(Key.TRANSLATION_X);
}
HashMap<String, KeyCycleOscillator> hashMap4 = this.mCycleMap;
if (hashMap4 != null) {
hashMap4.get(Key.TRANSLATION_Y);
}
for (int i2 = 0; i2 < i; i2++) {
float f3 = i2 * f2;
float f4 = this.mStaggerScale;
float f5 = 0.0f;
if (f4 != 1.0f) {
float f6 = this.mStaggerOffset;
if (f3 < f6) {
f3 = 0.0f;
}
if (f3 > f6 && f3 < 1.0d) {
f3 = (f3 - f6) * f4;
}
}
double d = f3;
Easing easing = this.mStartMotionPath.mKeyFrameEasing;
float f7 = Float.NaN;
Iterator<MotionPaths> it = this.mMotionPaths.iterator();
while (it.hasNext()) {
MotionPaths next = it.next();
Easing easing2 = next.mKeyFrameEasing;
if (easing2 != null) {
float f8 = next.time;
if (f8 < f3) {
easing = easing2;
f5 = f8;
} else if (Float.isNaN(f7)) {
f7 = next.time;
}
}
}
if (easing != null) {
if (Float.isNaN(f7)) {
f7 = 1.0f;
}
d = (((float) easing.get((f3 - f5) / f)) * (f7 - f5)) + f5;
}
this.mSpline[0].getPos(d, this.mInterpolateData);
CurveFit curveFit = this.mArcSpline;
if (curveFit != null) {
double[] dArr = this.mInterpolateData;
if (dArr.length > 0) {
curveFit.getPos(d, dArr);
}
}
this.mStartMotionPath.getBounds(this.mInterpolateVariables, this.mInterpolateData, fArr, i2 * 2);
}
}
public int buildKeyBounds(float[] fArr, int[] iArr) {
if (fArr == null) {
return 0;
}
double[] timePoints = this.mSpline[0].getTimePoints();
if (iArr != null) {
Iterator<MotionPaths> it = this.mMotionPaths.iterator();
int i = 0;
while (it.hasNext()) {
i++;
iArr[i] = it.next().mMode;
}
}
int i2 = 0;
for (double d : timePoints) {
this.mSpline[0].getPos(d, this.mInterpolateData);
this.mStartMotionPath.getBounds(this.mInterpolateVariables, this.mInterpolateData, fArr, i2);
i2 += 2;
}
return i2 / 2;
}
public int buildKeyFrames(float[] fArr, int[] iArr) {
if (fArr == null) {
return 0;
}
double[] timePoints = this.mSpline[0].getTimePoints();
if (iArr != null) {
Iterator<MotionPaths> it = this.mMotionPaths.iterator();
int i = 0;
while (it.hasNext()) {
i++;
iArr[i] = it.next().mMode;
}
}
int i2 = 0;
for (double d : timePoints) {
this.mSpline[0].getPos(d, this.mInterpolateData);
this.mStartMotionPath.getCenter(this.mInterpolateVariables, this.mInterpolateData, fArr, i2);
i2 += 2;
}
return i2 / 2;
}
/* JADX WARN: Removed duplicated region for block: B:33:0x007e */
/* JADX WARN: Removed duplicated region for block: B:43:0x00a2 */
/* JADX WARN: Removed duplicated region for block: B:49:0x00c8 */
/* JADX WARN: Removed duplicated region for block: B:54:0x00dd */
/* JADX WARN: Removed duplicated region for block: B:55:0x00e7 */
/* JADX WARN: Removed duplicated region for block: B:59:0x00f9 */
/* JADX WARN: Removed duplicated region for block: B:60:0x0105 */
/*
Code decompiled incorrectly, please refer to instructions dump.
*/
public void buildPath(float[] fArr, int i) {
SplineSet splineSet;
Easing easing;
Iterator<MotionPaths> it;
CurveFit curveFit;
float f;
int i2 = i;
float f2 = 1.0f;
float f3 = 1.0f / (i2 - 1);
HashMap<String, SplineSet> hashMap = this.mAttributesMap;
KeyCycleOscillator keyCycleOscillator = null;
SplineSet splineSet2 = hashMap == null ? null : hashMap.get(Key.TRANSLATION_X);
HashMap<String, SplineSet> hashMap2 = this.mAttributesMap;
SplineSet splineSet3 = hashMap2 == null ? null : hashMap2.get(Key.TRANSLATION_Y);
HashMap<String, KeyCycleOscillator> hashMap3 = this.mCycleMap;
KeyCycleOscillator keyCycleOscillator2 = hashMap3 == null ? null : hashMap3.get(Key.TRANSLATION_X);
HashMap<String, KeyCycleOscillator> hashMap4 = this.mCycleMap;
if (hashMap4 != null) {
keyCycleOscillator = hashMap4.get(Key.TRANSLATION_Y);
}
int i3 = 0;
while (i3 < i2) {
float f4 = i3 * f3;
float f5 = this.mStaggerScale;
if (f5 != f2) {
float f6 = this.mStaggerOffset;
if (f4 < f6) {
f4 = 0.0f;
}
if (f4 > f6) {
splineSet = splineSet2;
if (f4 < 1.0d) {
f4 = (f4 - f6) * f5;
}
double d = f4;
easing = this.mStartMotionPath.mKeyFrameEasing;
float f7 = Float.NaN;
it = this.mMotionPaths.iterator();
float f8 = 0.0f;
while (it.hasNext()) {
MotionPaths next = it.next();
Easing easing2 = next.mKeyFrameEasing;
if (easing2 != null) {
float f9 = next.time;
if (f9 < f4) {
f8 = f9;
easing = easing2;
} else if (Float.isNaN(f7)) {
f7 = next.time;
}
}
}
if (easing != null) {
if (Float.isNaN(f7)) {
f7 = 1.0f;
}
d = (((float) easing.get((f4 - f8) / f)) * (f7 - f8)) + f8;
}
this.mSpline[0].getPos(d, this.mInterpolateData);
curveFit = this.mArcSpline;
if (curveFit != null) {
double[] dArr = this.mInterpolateData;
if (dArr.length > 0) {
curveFit.getPos(d, dArr);
}
}
int i4 = i3 * 2;
this.mStartMotionPath.getCenter(this.mInterpolateVariables, this.mInterpolateData, fArr, i4);
if (keyCycleOscillator2 == null) {
fArr[i4] = keyCycleOscillator2.get(f4) + fArr[i4];
} else if (splineSet != null) {
splineSet2 = splineSet;
fArr[i4] = splineSet2.get(f4) + fArr[i4];
if (keyCycleOscillator != null) {
int i5 = i4 + 1;
fArr[i5] = keyCycleOscillator.get(f4) + fArr[i5];
} else if (splineSet3 != null) {
int i6 = i4 + 1;
fArr[i6] = splineSet3.get(f4) + fArr[i6];
}
i3++;
i2 = i;
f2 = 1.0f;
}
splineSet2 = splineSet;
if (keyCycleOscillator != null) {
}
i3++;
i2 = i;
f2 = 1.0f;
}
}
splineSet = splineSet2;
double d2 = f4;
easing = this.mStartMotionPath.mKeyFrameEasing;
float f72 = Float.NaN;
it = this.mMotionPaths.iterator();
float f82 = 0.0f;
while (it.hasNext()) {
}
if (easing != null) {
}
this.mSpline[0].getPos(d2, this.mInterpolateData);
curveFit = this.mArcSpline;
if (curveFit != null) {
}
int i42 = i3 * 2;
this.mStartMotionPath.getCenter(this.mInterpolateVariables, this.mInterpolateData, fArr, i42);
if (keyCycleOscillator2 == null) {
}
splineSet2 = splineSet;
if (keyCycleOscillator != null) {
}
i3++;
i2 = i;
f2 = 1.0f;
}
}
public void buildRect(float f, float[] fArr, int i) {
this.mSpline[0].getPos(getAdjustedPosition(f, null), this.mInterpolateData);
this.mStartMotionPath.getRect(this.mInterpolateVariables, this.mInterpolateData, fArr, i);
}
public void buildRectangles(float[] fArr, int i) {
float f = 1.0f / (i - 1);
for (int i2 = 0; i2 < i; i2++) {
this.mSpline[0].getPos(getAdjustedPosition(i2 * f, null), this.mInterpolateData);
this.mStartMotionPath.getRect(this.mInterpolateVariables, this.mInterpolateData, fArr, i2 * 8);
}
}
public int getAttributeValues(String str, float[] fArr, int i) {
SplineSet splineSet = this.mAttributesMap.get(str);
if (splineSet == null) {
return -1;
}
for (int i2 = 0; i2 < fArr.length; i2++) {
fArr[i2] = splineSet.get(i2 / (fArr.length - 1));
}
return fArr.length;
}
public void getDpDt(float f, float f2, float f3, float[] fArr) {
double[] dArr;
float adjustedPosition = getAdjustedPosition(f, this.mVelocity);
CurveFit[] curveFitArr = this.mSpline;
int i = 0;
if (curveFitArr != null) {
double d = adjustedPosition;
curveFitArr[0].getSlope(d, this.mInterpolateVelocity);
this.mSpline[0].getPos(d, this.mInterpolateData);
float f4 = this.mVelocity[0];
while (true) {
dArr = this.mInterpolateVelocity;
if (i >= dArr.length) {
break;
}
dArr[i] = dArr[i] * f4;
i++;
}
CurveFit curveFit = this.mArcSpline;
if (curveFit != null) {
double[] dArr2 = this.mInterpolateData;
if (dArr2.length > 0) {
curveFit.getPos(d, dArr2);
this.mArcSpline.getSlope(d, this.mInterpolateVelocity);
this.mStartMotionPath.setDpDt(f2, f3, fArr, this.mInterpolateVariables, this.mInterpolateVelocity, this.mInterpolateData);
return;
}
return;
}
this.mStartMotionPath.setDpDt(f2, f3, fArr, this.mInterpolateVariables, dArr, this.mInterpolateData);
return;
}
MotionPaths motionPaths = this.mEndMotionPath;
float f5 = motionPaths.f28x;
MotionPaths motionPaths2 = this.mStartMotionPath;
float f6 = f5 - motionPaths2.f28x;
float f7 = motionPaths.f29y - motionPaths2.f29y;
fArr[0] = (((motionPaths.width - motionPaths2.width) + f6) * f2) + ((1.0f - f2) * f6);
fArr[1] = (((motionPaths.height - motionPaths2.height) + f7) * f3) + ((1.0f - f3) * f7);
}
public int getDrawPath() {
int i = this.mStartMotionPath.mDrawPath;
Iterator<MotionPaths> it = this.mMotionPaths.iterator();
while (it.hasNext()) {
i = Math.max(i, it.next().mDrawPath);
}
return Math.max(i, this.mEndMotionPath.mDrawPath);
}
public float getFinalX() {
return this.mEndMotionPath.f28x;
}
public float getFinalY() {
return this.mEndMotionPath.f29y;
}
public MotionPaths getKeyFrame(int i) {
return this.mMotionPaths.get(i);
}
public int getKeyFrameInfo(int i, int[] iArr) {
float[] fArr = new float[2];
Iterator<Key> it = this.mKeyList.iterator();
int i2 = 0;
int i3 = 0;
while (it.hasNext()) {
Key next = it.next();
int i4 = next.mType;
if (i4 == i || i != -1) {
iArr[i3] = 0;
int i5 = i3 + 1;
iArr[i5] = i4;
int i6 = i5 + 1;
int i7 = next.mFramePosition;
iArr[i6] = i7;
this.mSpline[0].getPos(i7 / 100.0f, this.mInterpolateData);
this.mStartMotionPath.getCenter(this.mInterpolateVariables, this.mInterpolateData, fArr, 0);
int i8 = i6 + 1;
iArr[i8] = Float.floatToIntBits(fArr[0]);
int i9 = i8 + 1;
iArr[i9] = Float.floatToIntBits(fArr[1]);
if (next instanceof KeyPosition) {
KeyPosition keyPosition = (KeyPosition) next;
int i10 = i9 + 1;
iArr[i10] = keyPosition.mPositionType;
int i11 = i10 + 1;
iArr[i11] = Float.floatToIntBits(keyPosition.mPercentX);
i9 = i11 + 1;
iArr[i9] = Float.floatToIntBits(keyPosition.mPercentY);
}
int i12 = i9 + 1;
iArr[i3] = i12 - i3;
i2++;
i3 = i12;
}
}
return i2;
}
public float getKeyFrameParameter(int i, float f, float f2) {
MotionPaths motionPaths = this.mEndMotionPath;
float f3 = motionPaths.f28x;
MotionPaths motionPaths2 = this.mStartMotionPath;
float f4 = motionPaths2.f28x;
float f5 = f3 - f4;
float f6 = motionPaths.f29y;
float f7 = motionPaths2.f29y;
float f8 = f6 - f7;
float f9 = (motionPaths2.width / 2.0f) + f4;
float f10 = (motionPaths2.height / 2.0f) + f7;
float hypot = (float) Math.hypot(f5, f8);
if (hypot < 1.0E-7d) {
return Float.NaN;
}
float f11 = f - f9;
float f12 = f2 - f10;
if (((float) Math.hypot(f11, f12)) == 0.0f) {
return 0.0f;
}
float f13 = (f12 * f8) + (f11 * f5);
if (i == 0) {
return f13 / hypot;
}
if (i == 1) {
return (float) Math.sqrt((hypot * hypot) - (f13 * f13));
}
if (i == 2) {
return f11 / f5;
}
if (i == 3) {
return f12 / f5;
}
if (i == 4) {
return f11 / f8;
}
if (i != 5) {
return 0.0f;
}
return f12 / f8;
}
public KeyPositionBase getPositionKeyframe(int i, int i2, float f, float f2) {
RectF rectF = new RectF();
MotionPaths motionPaths = this.mStartMotionPath;
float f3 = motionPaths.f28x;
rectF.left = f3;
float f4 = motionPaths.f29y;
rectF.top = f4;
rectF.right = f3 + motionPaths.width;
rectF.bottom = f4 + motionPaths.height;
RectF rectF2 = new RectF();
MotionPaths motionPaths2 = this.mEndMotionPath;
float f5 = motionPaths2.f28x;
rectF2.left = f5;
float f6 = motionPaths2.f29y;
rectF2.top = f6;
rectF2.right = f5 + motionPaths2.width;
rectF2.bottom = f6 + motionPaths2.height;
Iterator<Key> it = this.mKeyList.iterator();
while (it.hasNext()) {
Key next = it.next();
if (next instanceof KeyPositionBase) {
KeyPositionBase keyPositionBase = (KeyPositionBase) next;
if (keyPositionBase.intersects(i, i2, rectF, rectF2, f, f2)) {
return keyPositionBase;
}
}
}
return null;
}
public void getPostLayoutDvDp(float f, int i, int i2, float f2, float f3, float[] fArr) {
float adjustedPosition = getAdjustedPosition(f, this.mVelocity);
HashMap<String, SplineSet> hashMap = this.mAttributesMap;
KeyCycleOscillator keyCycleOscillator = null;
SplineSet splineSet = hashMap == null ? null : hashMap.get(Key.TRANSLATION_X);
HashMap<String, SplineSet> hashMap2 = this.mAttributesMap;
SplineSet splineSet2 = hashMap2 == null ? null : hashMap2.get(Key.TRANSLATION_Y);
HashMap<String, SplineSet> hashMap3 = this.mAttributesMap;
SplineSet splineSet3 = hashMap3 == null ? null : hashMap3.get(Key.ROTATION);
HashMap<String, SplineSet> hashMap4 = this.mAttributesMap;
SplineSet splineSet4 = hashMap4 == null ? null : hashMap4.get(Key.SCALE_X);
HashMap<String, SplineSet> hashMap5 = this.mAttributesMap;
SplineSet splineSet5 = hashMap5 == null ? null : hashMap5.get(Key.SCALE_Y);
HashMap<String, KeyCycleOscillator> hashMap6 = this.mCycleMap;
KeyCycleOscillator keyCycleOscillator2 = hashMap6 == null ? null : hashMap6.get(Key.TRANSLATION_X);
HashMap<String, KeyCycleOscillator> hashMap7 = this.mCycleMap;
KeyCycleOscillator keyCycleOscillator3 = hashMap7 == null ? null : hashMap7.get(Key.TRANSLATION_Y);
HashMap<String, KeyCycleOscillator> hashMap8 = this.mCycleMap;
KeyCycleOscillator keyCycleOscillator4 = hashMap8 == null ? null : hashMap8.get(Key.ROTATION);
HashMap<String, KeyCycleOscillator> hashMap9 = this.mCycleMap;
KeyCycleOscillator keyCycleOscillator5 = hashMap9 == null ? null : hashMap9.get(Key.SCALE_X);
HashMap<String, KeyCycleOscillator> hashMap10 = this.mCycleMap;
if (hashMap10 != null) {
keyCycleOscillator = hashMap10.get(Key.SCALE_Y);
}
VelocityMatrix velocityMatrix = new VelocityMatrix();
velocityMatrix.clear();
velocityMatrix.setRotationVelocity(splineSet3, adjustedPosition);
velocityMatrix.setTranslationVelocity(splineSet, splineSet2, adjustedPosition);
velocityMatrix.setScaleVelocity(splineSet4, splineSet5, adjustedPosition);
velocityMatrix.setRotationVelocity(keyCycleOscillator4, adjustedPosition);
velocityMatrix.setTranslationVelocity(keyCycleOscillator2, keyCycleOscillator3, adjustedPosition);
velocityMatrix.setScaleVelocity(keyCycleOscillator5, keyCycleOscillator, adjustedPosition);
CurveFit curveFit = this.mArcSpline;
if (curveFit != null) {
double[] dArr = this.mInterpolateData;
if (dArr.length > 0) {
double d = adjustedPosition;
curveFit.getPos(d, dArr);
this.mArcSpline.getSlope(d, this.mInterpolateVelocity);
this.mStartMotionPath.setDpDt(f2, f3, fArr, this.mInterpolateVariables, this.mInterpolateVelocity, this.mInterpolateData);
}
velocityMatrix.applyTransform(f2, f3, i, i2, fArr);
return;
}
int i3 = 0;
if (this.mSpline != null) {
double adjustedPosition2 = getAdjustedPosition(adjustedPosition, this.mVelocity);
this.mSpline[0].getSlope(adjustedPosition2, this.mInterpolateVelocity);
this.mSpline[0].getPos(adjustedPosition2, this.mInterpolateData);
float f4 = this.mVelocity[0];
while (true) {
double[] dArr2 = this.mInterpolateVelocity;
if (i3 < dArr2.length) {
dArr2[i3] = dArr2[i3] * f4;
i3++;
} else {
this.mStartMotionPath.setDpDt(f2, f3, fArr, this.mInterpolateVariables, dArr2, this.mInterpolateData);
velocityMatrix.applyTransform(f2, f3, i, i2, fArr);
return;
}
}
} else {
MotionPaths motionPaths = this.mEndMotionPath;
float f5 = motionPaths.f28x;
MotionPaths motionPaths2 = this.mStartMotionPath;
float f6 = f5 - motionPaths2.f28x;
float f7 = motionPaths.f29y - motionPaths2.f29y;
fArr[0] = (((motionPaths.width - motionPaths2.width) + f6) * f2) + ((1.0f - f2) * f6);
fArr[1] = (((motionPaths.height - motionPaths2.height) + f7) * f3) + ((1.0f - f3) * f7);
velocityMatrix.clear();
velocityMatrix.setRotationVelocity(splineSet3, adjustedPosition);
velocityMatrix.setTranslationVelocity(splineSet, splineSet2, adjustedPosition);
velocityMatrix.setScaleVelocity(splineSet4, splineSet5, adjustedPosition);
velocityMatrix.setRotationVelocity(keyCycleOscillator4, adjustedPosition);
velocityMatrix.setTranslationVelocity(keyCycleOscillator2, keyCycleOscillator3, adjustedPosition);
velocityMatrix.setScaleVelocity(keyCycleOscillator5, keyCycleOscillator, adjustedPosition);
velocityMatrix.applyTransform(f2, f3, i, i2, fArr);
}
}
public float getStartX() {
return this.mStartMotionPath.f28x;
}
public float getStartY() {
return this.mStartMotionPath.f29y;
}
public int getkeyFramePositions(int[] iArr, float[] fArr) {
Iterator<Key> it = this.mKeyList.iterator();
int i = 0;
int i2 = 0;
while (it.hasNext()) {
Key next = it.next();
i++;
int i3 = next.mFramePosition;
iArr[i] = (next.mType * 1000) + i3;
this.mSpline[0].getPos(i3 / 100.0f, this.mInterpolateData);
this.mStartMotionPath.getCenter(this.mInterpolateVariables, this.mInterpolateData, fArr, i2);
i2 += 2;
}
return i;
}
public boolean interpolate(View view, float f, long j, KeyCache keyCache) {
boolean z2;
TimeCycleSplineSet.PathRotate pathRotate;
double d;
float adjustedPosition = getAdjustedPosition(f, null);
HashMap<String, SplineSet> hashMap = this.mAttributesMap;
if (hashMap != null) {
for (SplineSet splineSet : hashMap.values()) {
splineSet.setProperty(view, adjustedPosition);
}
}
HashMap<String, TimeCycleSplineSet> hashMap2 = this.mTimeCycleAttributesMap;
if (hashMap2 != null) {
pathRotate = null;
boolean z3 = false;
for (TimeCycleSplineSet timeCycleSplineSet : hashMap2.values()) {
if (timeCycleSplineSet instanceof TimeCycleSplineSet.PathRotate) {
pathRotate = (TimeCycleSplineSet.PathRotate) timeCycleSplineSet;
} else {
z3 |= timeCycleSplineSet.setProperty(view, adjustedPosition, j, keyCache);
}
}
z2 = z3;
} else {
pathRotate = null;
z2 = false;
}
CurveFit[] curveFitArr = this.mSpline;
if (curveFitArr != null) {
double d2 = adjustedPosition;
curveFitArr[0].getPos(d2, this.mInterpolateData);
this.mSpline[0].getSlope(d2, this.mInterpolateVelocity);
CurveFit curveFit = this.mArcSpline;
if (curveFit != null) {
double[] dArr = this.mInterpolateData;
if (dArr.length > 0) {
curveFit.getPos(d2, dArr);
this.mArcSpline.getSlope(d2, this.mInterpolateVelocity);
}
}
this.mStartMotionPath.setView(view, this.mInterpolateVariables, this.mInterpolateData, this.mInterpolateVelocity, null);
HashMap<String, SplineSet> hashMap3 = this.mAttributesMap;
if (hashMap3 != null) {
for (SplineSet splineSet2 : hashMap3.values()) {
if (splineSet2 instanceof SplineSet.PathRotate) {
double[] dArr2 = this.mInterpolateVelocity;
((SplineSet.PathRotate) splineSet2).setPathRotate(view, adjustedPosition, dArr2[0], dArr2[1]);
}
}
}
if (pathRotate != null) {
double[] dArr3 = this.mInterpolateVelocity;
d = d2;
z2 = pathRotate.setPathRotate(view, keyCache, adjustedPosition, j, dArr3[0], dArr3[1]) | z2;
} else {
d = d2;
}
int i = 1;
while (true) {
CurveFit[] curveFitArr2 = this.mSpline;
if (i >= curveFitArr2.length) {
break;
}
curveFitArr2[i].getPos(d, this.mValuesBuff);
this.mStartMotionPath.attributes.get(this.mAttributeNames[i - 1]).setInterpolatedValue(view, this.mValuesBuff);
i++;
}
MotionConstrainedPoint motionConstrainedPoint = this.mStartPoint;
if (motionConstrainedPoint.mVisibilityMode == 0) {
if (adjustedPosition <= 0.0f) {
view.setVisibility(motionConstrainedPoint.visibility);
} else if (adjustedPosition >= 1.0f) {
view.setVisibility(this.mEndPoint.visibility);
} else if (this.mEndPoint.visibility != motionConstrainedPoint.visibility) {
view.setVisibility(0);
}
}
if (this.mKeyTriggers != null) {
int i2 = 0;
while (true) {
KeyTrigger[] keyTriggerArr = this.mKeyTriggers;
if (i2 >= keyTriggerArr.length) {
break;
}
keyTriggerArr[i2].conditionallyFire(adjustedPosition, view);
i2++;
}
}
} else {
MotionPaths motionPaths = this.mStartMotionPath;
float f2 = motionPaths.f28x;
MotionPaths motionPaths2 = this.mEndMotionPath;
float a = a.a(motionPaths2.f28x, f2, adjustedPosition, f2);
float f3 = motionPaths.f29y;
float a2 = a.a(motionPaths2.f29y, f3, adjustedPosition, f3);
float f4 = motionPaths.width;
float f5 = motionPaths2.width;
float a3 = a.a(f5, f4, adjustedPosition, f4);
float f6 = motionPaths.height;
float f7 = motionPaths2.height;
float f8 = a + 0.5f;
int i3 = (int) f8;
float f9 = a2 + 0.5f;
int i4 = (int) f9;
int i5 = (int) (f8 + a3);
int a4 = (int) (f9 + a.a(f7, f6, adjustedPosition, f6));
int i6 = i5 - i3;
int i7 = a4 - i4;
if (!(f5 == f4 && f7 == f6)) {
view.measure(View.MeasureSpec.makeMeasureSpec(i6, BasicMeasure.EXACTLY), View.MeasureSpec.makeMeasureSpec(i7, BasicMeasure.EXACTLY));
}
view.layout(i3, i4, i5, a4);
}
HashMap<String, KeyCycleOscillator> hashMap4 = this.mCycleMap;
if (hashMap4 != null) {
for (KeyCycleOscillator keyCycleOscillator : hashMap4.values()) {
if (keyCycleOscillator instanceof KeyCycleOscillator.PathRotateSet) {
double[] dArr4 = this.mInterpolateVelocity;
((KeyCycleOscillator.PathRotateSet) keyCycleOscillator).setPathRotate(view, adjustedPosition, dArr4[0], dArr4[1]);
} else {
keyCycleOscillator.setProperty(view, adjustedPosition);
}
}
}
return z2;
}
public String name() {
return this.mView.getContext().getResources().getResourceEntryName(this.mView.getId());
}
public void positionKeyframe(View view, KeyPositionBase keyPositionBase, float f, float f2, String[] strArr, float[] fArr) {
RectF rectF = new RectF();
MotionPaths motionPaths = this.mStartMotionPath;
float f3 = motionPaths.f28x;
rectF.left = f3;
float f4 = motionPaths.f29y;
rectF.top = f4;
rectF.right = f3 + motionPaths.width;
rectF.bottom = f4 + motionPaths.height;
RectF rectF2 = new RectF();
MotionPaths motionPaths2 = this.mEndMotionPath;
float f5 = motionPaths2.f28x;
rectF2.left = f5;
float f6 = motionPaths2.f29y;
rectF2.top = f6;
rectF2.right = f5 + motionPaths2.width;
rectF2.bottom = f6 + motionPaths2.height;
keyPositionBase.positionAttributes(view, rectF, rectF2, f, f2, strArr, fArr);
}
public void setDrawPath(int i) {
this.mStartMotionPath.mDrawPath = i;
}
public void setEndState(ConstraintWidget constraintWidget, ConstraintSet constraintSet) {
MotionPaths motionPaths = this.mEndMotionPath;
motionPaths.time = 1.0f;
motionPaths.position = 1.0f;
readView(motionPaths);
this.mEndMotionPath.setBounds(constraintWidget.getX(), constraintWidget.getY(), constraintWidget.getWidth(), constraintWidget.getHeight());
this.mEndMotionPath.applyParameters(constraintSet.getParameters(this.mId));
this.mEndPoint.setState(constraintWidget, constraintSet, this.mId);
}
public void setPathMotionArc(int i) {
this.mPathMotionArc = i;
}
public void setStartCurrentState(View view) {
MotionPaths motionPaths = this.mStartMotionPath;
motionPaths.time = 0.0f;
motionPaths.position = 0.0f;
motionPaths.setBounds(view.getX(), view.getY(), view.getWidth(), view.getHeight());
this.mStartPoint.setState(view);
}
public void setStartState(ConstraintWidget constraintWidget, ConstraintSet constraintSet) {
MotionPaths motionPaths = this.mStartMotionPath;
motionPaths.time = 0.0f;
motionPaths.position = 0.0f;
readView(motionPaths);
this.mStartMotionPath.setBounds(constraintWidget.getX(), constraintWidget.getY(), constraintWidget.getWidth(), constraintWidget.getHeight());
ConstraintSet.Constraint parameters = constraintSet.getParameters(this.mId);
this.mStartMotionPath.applyParameters(parameters);
this.mMotionStagger = parameters.motion.mMotionStagger;
this.mStartPoint.setState(constraintWidget, constraintSet, this.mId);
}
public void setView(View view) {
this.mView = view;
this.mId = view.getId();
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams instanceof ConstraintLayout.LayoutParams) {
this.mConstraintTag = ((ConstraintLayout.LayoutParams) layoutParams).getConstraintTag();
}
}
public void setup(int i, int i2, float f, long j) {
ArrayList arrayList;
String[] strArr;
TimeCycleSplineSet timeCycleSplineSet;
ConstraintAttribute constraintAttribute;
SplineSet splineSet;
ConstraintAttribute constraintAttribute2;
new HashSet();
HashSet<String> hashSet = new HashSet<>();
HashSet<String> hashSet2 = new HashSet<>();
HashSet<String> hashSet3 = new HashSet<>();
HashMap<String, Integer> hashMap = new HashMap<>();
int i3 = this.mPathMotionArc;
if (i3 != Key.UNSET) {
this.mStartMotionPath.mPathMotionArc = i3;
}
this.mStartPoint.different(this.mEndPoint, hashSet2);
ArrayList<Key> arrayList2 = this.mKeyList;
if (arrayList2 != null) {
Iterator<Key> it = arrayList2.iterator();
arrayList = null;
while (it.hasNext()) {
Key next = it.next();
if (next instanceof KeyPosition) {
KeyPosition keyPosition = (KeyPosition) next;
insertKey(new MotionPaths(i, i2, keyPosition, this.mStartMotionPath, this.mEndMotionPath));
int i4 = keyPosition.mCurveFit;
if (i4 != Key.UNSET) {
this.mCurveFitType = i4;
}
} else if (next instanceof KeyCycle) {
next.getAttributeNames(hashSet3);
} else if (next instanceof KeyTimeCycle) {
next.getAttributeNames(hashSet);
} else if (next instanceof KeyTrigger) {
if (arrayList == null) {
arrayList = new ArrayList();
}
arrayList.add((KeyTrigger) next);
} else {
next.setInterpolation(hashMap);
next.getAttributeNames(hashSet2);
}
}
} else {
arrayList = null;
}
char c = 0;
if (arrayList != null) {
this.mKeyTriggers = (KeyTrigger[]) arrayList.toArray(new KeyTrigger[0]);
}
char c2 = 1;
if (!hashSet2.isEmpty()) {
this.mAttributesMap = new HashMap<>();
Iterator<String> it2 = hashSet2.iterator();
while (it2.hasNext()) {
String next2 = it2.next();
if (next2.startsWith("CUSTOM,")) {
SparseArray sparseArray = new SparseArray();
String str = next2.split(",")[c2];
Iterator<Key> it3 = this.mKeyList.iterator();
while (it3.hasNext()) {
Key next3 = it3.next();
HashMap<String, ConstraintAttribute> hashMap2 = next3.mCustomConstraints;
if (!(hashMap2 == null || (constraintAttribute2 = hashMap2.get(str)) == null)) {
sparseArray.append(next3.mFramePosition, constraintAttribute2);
}
}
splineSet = SplineSet.makeCustomSpline(next2, sparseArray);
} else {
splineSet = SplineSet.makeSpline(next2);
}
if (splineSet != null) {
splineSet.setType(next2);
this.mAttributesMap.put(next2, splineSet);
}
c2 = 1;
}
ArrayList<Key> arrayList3 = this.mKeyList;
if (arrayList3 != null) {
Iterator<Key> it4 = arrayList3.iterator();
while (it4.hasNext()) {
Key next4 = it4.next();
if (next4 instanceof KeyAttributes) {
next4.addValues(this.mAttributesMap);
}
}
}
this.mStartPoint.addValues(this.mAttributesMap, 0);
this.mEndPoint.addValues(this.mAttributesMap, 100);
for (String str2 : this.mAttributesMap.keySet()) {
this.mAttributesMap.get(str2).setup(hashMap.containsKey(str2) ? hashMap.get(str2).intValue() : 0);
}
}
if (!hashSet.isEmpty()) {
if (this.mTimeCycleAttributesMap == null) {
this.mTimeCycleAttributesMap = new HashMap<>();
}
Iterator<String> it5 = hashSet.iterator();
while (it5.hasNext()) {
String next5 = it5.next();
if (!this.mTimeCycleAttributesMap.containsKey(next5)) {
if (next5.startsWith("CUSTOM,")) {
SparseArray sparseArray2 = new SparseArray();
String str3 = next5.split(",")[1];
Iterator<Key> it6 = this.mKeyList.iterator();
while (it6.hasNext()) {
Key next6 = it6.next();
HashMap<String, ConstraintAttribute> hashMap3 = next6.mCustomConstraints;
if (!(hashMap3 == null || (constraintAttribute = hashMap3.get(str3)) == null)) {
sparseArray2.append(next6.mFramePosition, constraintAttribute);
}
}
timeCycleSplineSet = TimeCycleSplineSet.makeCustomSpline(next5, sparseArray2);
} else {
timeCycleSplineSet = TimeCycleSplineSet.makeSpline(next5, j);
}
if (timeCycleSplineSet != null) {
timeCycleSplineSet.setType(next5);
this.mTimeCycleAttributesMap.put(next5, timeCycleSplineSet);
}
}
}
ArrayList<Key> arrayList4 = this.mKeyList;
if (arrayList4 != null) {
Iterator<Key> it7 = arrayList4.iterator();
while (it7.hasNext()) {
Key next7 = it7.next();
if (next7 instanceof KeyTimeCycle) {
((KeyTimeCycle) next7).addTimeValues(this.mTimeCycleAttributesMap);
}
}
}
for (String str4 : this.mTimeCycleAttributesMap.keySet()) {
this.mTimeCycleAttributesMap.get(str4).setup(hashMap.containsKey(str4) ? hashMap.get(str4).intValue() : 0);
}
}
int i5 = 2;
int size = this.mMotionPaths.size() + 2;
MotionPaths[] motionPathsArr = new MotionPaths[size];
motionPathsArr[0] = this.mStartMotionPath;
motionPathsArr[size - 1] = this.mEndMotionPath;
if (this.mMotionPaths.size() > 0 && this.mCurveFitType == -1) {
this.mCurveFitType = 0;
}
Iterator<MotionPaths> it8 = this.mMotionPaths.iterator();
int i6 = 1;
while (it8.hasNext()) {
i6++;
motionPathsArr[i6] = it8.next();
}
HashSet hashSet4 = new HashSet();
for (String str5 : this.mEndMotionPath.attributes.keySet()) {
if (this.mStartMotionPath.attributes.containsKey(str5)) {
if (!hashSet2.contains("CUSTOM," + str5)) {
hashSet4.add(str5);
}
}
}
String[] strArr2 = (String[]) hashSet4.toArray(new String[0]);
this.mAttributeNames = strArr2;
this.mAttributeInterpCount = new int[strArr2.length];
int i7 = 0;
while (true) {
strArr = this.mAttributeNames;
if (i7 >= strArr.length) {
break;
}
String str6 = strArr[i7];
this.mAttributeInterpCount[i7] = 0;
int i8 = 0;
while (true) {
if (i8 >= size) {
break;
} else if (motionPathsArr[i8].attributes.containsKey(str6)) {
int[] iArr = this.mAttributeInterpCount;
iArr[i7] = motionPathsArr[i8].attributes.get(str6).noOfInterpValues() + iArr[i7];
break;
} else {
i8++;
}
}
i7++;
}
boolean z2 = motionPathsArr[0].mPathMotionArc != Key.UNSET;
int length = 18 + strArr.length;
boolean[] zArr = new boolean[length];
for (int i9 = 1; i9 < size; i9++) {
motionPathsArr[i9].different(motionPathsArr[i9 - 1], zArr, this.mAttributeNames, z2);
}
int i10 = 0;
for (int i11 = 1; i11 < length; i11++) {
if (zArr[i11]) {
i10++;
}
}
int[] iArr2 = new int[i10];
this.mInterpolateVariables = iArr2;
this.mInterpolateData = new double[iArr2.length];
this.mInterpolateVelocity = new double[iArr2.length];
int i12 = 0;
for (int i13 = 1; i13 < length; i13++) {
if (zArr[i13]) {
i12++;
this.mInterpolateVariables[i12] = i13;
}
}
double[][] dArr = (double[][]) Array.newInstance(double.class, size, this.mInterpolateVariables.length);
double[] dArr2 = new double[size];
for (int i14 = 0; i14 < size; i14++) {
motionPathsArr[i14].fillStandard(dArr[i14], this.mInterpolateVariables);
dArr2[i14] = motionPathsArr[i14].time;
}
int i15 = 0;
while (true) {
int[] iArr3 = this.mInterpolateVariables;
if (i15 >= iArr3.length) {
break;
}
if (iArr3[i15] < MotionPaths.names.length) {
String H = a.H(new StringBuilder(), MotionPaths.names[this.mInterpolateVariables[i15]], " [");
for (int i16 = 0; i16 < size; i16++) {
StringBuilder S = a.S(H);
S.append(dArr[i16][i15]);
H = S.toString();
}
}
i15++;
}
this.mSpline = new CurveFit[this.mAttributeNames.length + 1];
int i17 = 0;
while (true) {
String[] strArr3 = this.mAttributeNames;
if (i17 >= strArr3.length) {
break;
}
String str7 = strArr3[i17];
int i18 = 0;
double[] dArr3 = null;
int i19 = 0;
double[][] dArr4 = null;
while (i18 < size) {
if (motionPathsArr[i18].hasCustomData(str7)) {
if (dArr4 == null) {
dArr3 = new double[size];
int[] iArr4 = new int[i5];
iArr4[1] = motionPathsArr[i18].getCustomDataCount(str7);
iArr4[c] = size;
dArr4 = (double[][]) Array.newInstance(double.class, iArr4);
}
dArr3[i19] = motionPathsArr[i18].time;
motionPathsArr[i18].getCustomData(str7, dArr4[i19], 0);
i19++;
}
i18++;
i5 = 2;
c = 0;
}
i17++;
this.mSpline[i17] = CurveFit.get(this.mCurveFitType, Arrays.copyOf(dArr3, i19), (double[][]) Arrays.copyOf(dArr4, i19));
i5 = 2;
c = 0;
}
this.mSpline[0] = CurveFit.get(this.mCurveFitType, dArr2, dArr);
if (motionPathsArr[0].mPathMotionArc != Key.UNSET) {
int[] iArr5 = new int[size];
double[] dArr5 = new double[size];
double[][] dArr6 = (double[][]) Array.newInstance(double.class, size, 2);
for (int i20 = 0; i20 < size; i20++) {
iArr5[i20] = motionPathsArr[i20].mPathMotionArc;
dArr5[i20] = motionPathsArr[i20].time;
dArr6[i20][0] = motionPathsArr[i20].f28x;
dArr6[i20][1] = motionPathsArr[i20].f29y;
}
this.mArcSpline = CurveFit.getArc(iArr5, dArr5, dArr6);
}
float f2 = Float.NaN;
this.mCycleMap = new HashMap<>();
if (this.mKeyList != null) {
Iterator<String> it9 = hashSet3.iterator();
while (it9.hasNext()) {
String next8 = it9.next();
KeyCycleOscillator makeSpline = KeyCycleOscillator.makeSpline(next8);
if (makeSpline != null) {
if (makeSpline.variesByPath() && Float.isNaN(f2)) {
f2 = getPreCycleDistance();
}
makeSpline.setType(next8);
this.mCycleMap.put(next8, makeSpline);
}
}
Iterator<Key> it10 = this.mKeyList.iterator();
while (it10.hasNext()) {
Key next9 = it10.next();
if (next9 instanceof KeyCycle) {
((KeyCycle) next9).addCycleValues(this.mCycleMap);
}
}
for (KeyCycleOscillator keyCycleOscillator : this.mCycleMap.values()) {
keyCycleOscillator.setup(f2);
}
}
}
public String toString() {
StringBuilder S = a.S(" start: x: ");
S.append(this.mStartMotionPath.f28x);
S.append(" y: ");
S.append(this.mStartMotionPath.f29y);
S.append(" end: x: ");
S.append(this.mEndMotionPath.f28x);
S.append(" y: ");
S.append(this.mEndMotionPath.f29y);
return S.toString();
}
}