2021-06-27 20:44:35 +00:00
|
|
|
package androidx.constraintlayout.motion.widget;
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.SparseArray;
|
|
|
|
import android.view.View;
|
|
|
|
import androidx.constraintlayout.motion.utils.CurveFit;
|
|
|
|
import androidx.constraintlayout.widget.ConstraintAttribute;
|
2021-12-21 23:37:30 +00:00
|
|
|
import b.d.b.a.a;
|
2021-06-27 20:44:35 +00:00
|
|
|
import java.lang.reflect.Array;
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.util.Arrays;
|
|
|
|
public abstract class SplineSet {
|
|
|
|
private static final String TAG = "SplineSet";
|
|
|
|
private int count;
|
|
|
|
public CurveFit mCurveFit;
|
|
|
|
public int[] mTimePoints = new int[10];
|
|
|
|
private String mType;
|
|
|
|
public float[] mValues = new float[10];
|
|
|
|
|
|
|
|
public static class AlphaSet extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setAlpha(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class CustomSet extends SplineSet {
|
|
|
|
public String mAttributeName;
|
|
|
|
public SparseArray<ConstraintAttribute> mConstraintAttributeList;
|
|
|
|
public float[] mTempValues;
|
|
|
|
|
|
|
|
public CustomSet(String str, SparseArray<ConstraintAttribute> sparseArray) {
|
|
|
|
this.mAttributeName = str.split(",")[1];
|
|
|
|
this.mConstraintAttributeList = sparseArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setPoint(int i, float f) {
|
|
|
|
throw new RuntimeException("don't call for custom attribute call setPoint(pos, ConstraintAttribute)");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPoint(int i, ConstraintAttribute constraintAttribute) {
|
|
|
|
this.mConstraintAttributeList.append(i, constraintAttribute);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
this.mCurveFit.getPos((double) f, this.mTempValues);
|
|
|
|
this.mConstraintAttributeList.valueAt(0).setInterpolatedValue(view, this.mTempValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setup(int i) {
|
|
|
|
int size = this.mConstraintAttributeList.size();
|
|
|
|
int noOfInterpValues = this.mConstraintAttributeList.valueAt(0).noOfInterpValues();
|
|
|
|
double[] dArr = new double[size];
|
|
|
|
this.mTempValues = new float[noOfInterpValues];
|
|
|
|
int[] iArr = new int[2];
|
|
|
|
iArr[1] = noOfInterpValues;
|
|
|
|
iArr[0] = size;
|
|
|
|
double[][] dArr2 = (double[][]) Array.newInstance(double.class, iArr);
|
|
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
|
|
dArr[i2] = ((double) this.mConstraintAttributeList.keyAt(i2)) * 0.01d;
|
|
|
|
this.mConstraintAttributeList.valueAt(i2).getValuesToInterpolate(this.mTempValues);
|
|
|
|
int i3 = 0;
|
|
|
|
while (true) {
|
|
|
|
float[] fArr = this.mTempValues;
|
|
|
|
if (i3 >= fArr.length) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dArr2[i2][i3] = (double) fArr[i3];
|
|
|
|
i3++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.mCurveFit = CurveFit.get(i, dArr, dArr2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ElevationSet extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setElevation(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class PathRotate extends SplineSet {
|
|
|
|
public void setPathRotate(View view, float f, double d, double d2) {
|
|
|
|
view.setRotation(get(f) + ((float) Math.toDegrees(Math.atan2(d2, d))));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class PivotXset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setPivotX(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class PivotYset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setPivotY(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ProgressSet extends SplineSet {
|
|
|
|
public boolean mNoMethod = false;
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
if (view instanceof MotionLayout) {
|
|
|
|
((MotionLayout) view).setProgress(get(f));
|
|
|
|
} else if (!this.mNoMethod) {
|
|
|
|
Method method = null;
|
|
|
|
try {
|
|
|
|
method = view.getClass().getMethod("setProgress", Float.TYPE);
|
|
|
|
} catch (NoSuchMethodException unused) {
|
|
|
|
this.mNoMethod = true;
|
|
|
|
}
|
|
|
|
if (method != null) {
|
|
|
|
try {
|
|
|
|
method.invoke(view, Float.valueOf(get(f)));
|
|
|
|
} catch (IllegalAccessException e) {
|
2021-08-09 22:50:01 +00:00
|
|
|
Log.e(SplineSet.TAG, "unable to setProgress", e);
|
2021-06-27 20:44:35 +00:00
|
|
|
} catch (InvocationTargetException e2) {
|
2021-08-09 22:50:01 +00:00
|
|
|
Log.e(SplineSet.TAG, "unable to setProgress", e2);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class RotationSet extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setRotation(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class RotationXset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setRotationX(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class RotationYset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setRotationY(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ScaleXset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setScaleX(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ScaleYset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setScaleY(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class Sort {
|
|
|
|
private Sort() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void doubleQuickSort(int[] iArr, float[] fArr, int i, int i2) {
|
|
|
|
int[] iArr2 = new int[(iArr.length + 10)];
|
|
|
|
iArr2[0] = i2;
|
|
|
|
iArr2[1] = i;
|
|
|
|
int i3 = 2;
|
|
|
|
while (i3 > 0) {
|
|
|
|
int i4 = i3 - 1;
|
|
|
|
int i5 = iArr2[i4];
|
|
|
|
i3 = i4 - 1;
|
|
|
|
int i6 = iArr2[i3];
|
|
|
|
if (i5 < i6) {
|
|
|
|
int partition = partition(iArr, fArr, i5, i6);
|
|
|
|
int i7 = i3 + 1;
|
|
|
|
iArr2[i3] = partition - 1;
|
|
|
|
int i8 = i7 + 1;
|
|
|
|
iArr2[i7] = i5;
|
|
|
|
int i9 = i8 + 1;
|
|
|
|
iArr2[i8] = i6;
|
|
|
|
i3 = i9 + 1;
|
|
|
|
iArr2[i9] = partition + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int partition(int[] iArr, float[] fArr, int i, int i2) {
|
|
|
|
int i3 = iArr[i2];
|
|
|
|
int i4 = i;
|
|
|
|
while (i < i2) {
|
|
|
|
if (iArr[i] <= i3) {
|
|
|
|
swap(iArr, fArr, i4, i);
|
|
|
|
i4++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
swap(iArr, fArr, i4, i2);
|
|
|
|
return i4;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void swap(int[] iArr, float[] fArr, int i, int i2) {
|
|
|
|
int i3 = iArr[i];
|
|
|
|
iArr[i] = iArr[i2];
|
|
|
|
iArr[i2] = i3;
|
|
|
|
float f = fArr[i];
|
|
|
|
fArr[i] = fArr[i2];
|
|
|
|
fArr[i2] = f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class TranslationXset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setTranslationX(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class TranslationYset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setTranslationY(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class TranslationZset extends SplineSet {
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.SplineSet
|
|
|
|
public void setProperty(View view, float f) {
|
|
|
|
view.setTranslationZ(get(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SplineSet makeCustomSpline(String str, SparseArray<ConstraintAttribute> sparseArray) {
|
|
|
|
return new CustomSet(str, sparseArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SplineSet makeSpline(String str) {
|
|
|
|
str.hashCode();
|
2021-12-21 23:37:30 +00:00
|
|
|
char c = 65535;
|
2021-06-27 20:44:35 +00:00
|
|
|
switch (str.hashCode()) {
|
|
|
|
case -1249320806:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.ROTATION_X)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 0;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -1249320805:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.ROTATION_Y)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 1;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -1225497657:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.TRANSLATION_X)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 2;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -1225497656:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.TRANSLATION_Y)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 3;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -1225497655:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.TRANSLATION_Z)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 4;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -1001078227:
|
|
|
|
if (str.equals("progress")) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 5;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -908189618:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.SCALE_X)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 6;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -908189617:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.SCALE_Y)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 7;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -797520672:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.WAVE_VARIES_BY)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = '\b';
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -760884510:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.PIVOT_X)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = '\t';
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -760884509:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.PIVOT_Y)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = '\n';
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -40300674:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.ROTATION)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 11;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -4379043:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.ELEVATION)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = '\f';
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 37232917:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.TRANSITION_PATH_ROTATE)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = '\r';
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 92909918:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.ALPHA)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 14;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 156108012:
|
2021-08-09 22:50:01 +00:00
|
|
|
if (str.equals(Key.WAVE_OFFSET)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
c = 15;
|
2021-06-27 20:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-12-21 23:37:30 +00:00
|
|
|
switch (c) {
|
2021-06-27 20:44:35 +00:00
|
|
|
case 0:
|
|
|
|
return new RotationXset();
|
|
|
|
case 1:
|
|
|
|
return new RotationYset();
|
|
|
|
case 2:
|
|
|
|
return new TranslationXset();
|
|
|
|
case 3:
|
|
|
|
return new TranslationYset();
|
|
|
|
case 4:
|
|
|
|
return new TranslationZset();
|
|
|
|
case 5:
|
|
|
|
return new ProgressSet();
|
|
|
|
case 6:
|
|
|
|
return new ScaleXset();
|
|
|
|
case 7:
|
|
|
|
return new ScaleYset();
|
|
|
|
case '\b':
|
|
|
|
return new AlphaSet();
|
|
|
|
case '\t':
|
|
|
|
return new PivotXset();
|
|
|
|
case '\n':
|
|
|
|
return new PivotYset();
|
|
|
|
case 11:
|
|
|
|
return new RotationSet();
|
|
|
|
case '\f':
|
|
|
|
return new ElevationSet();
|
|
|
|
case '\r':
|
|
|
|
return new PathRotate();
|
|
|
|
case 14:
|
|
|
|
return new AlphaSet();
|
|
|
|
case 15:
|
|
|
|
return new AlphaSet();
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public float get(float f) {
|
|
|
|
return (float) this.mCurveFit.getPos((double) f, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public CurveFit getCurveFit() {
|
|
|
|
return this.mCurveFit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getSlope(float f) {
|
|
|
|
return (float) this.mCurveFit.getSlope((double) f, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPoint(int i, float f) {
|
|
|
|
int[] iArr = this.mTimePoints;
|
|
|
|
if (iArr.length < this.count + 1) {
|
|
|
|
this.mTimePoints = Arrays.copyOf(iArr, iArr.length * 2);
|
|
|
|
float[] fArr = this.mValues;
|
|
|
|
this.mValues = Arrays.copyOf(fArr, fArr.length * 2);
|
|
|
|
}
|
|
|
|
int[] iArr2 = this.mTimePoints;
|
|
|
|
int i2 = this.count;
|
|
|
|
iArr2[i2] = i;
|
|
|
|
this.mValues[i2] = f;
|
|
|
|
this.count = i2 + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void setProperty(View view, float f);
|
|
|
|
|
|
|
|
public void setType(String str) {
|
|
|
|
this.mType = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setup(int i) {
|
|
|
|
int i2 = this.count;
|
|
|
|
if (i2 != 0) {
|
|
|
|
Sort.doubleQuickSort(this.mTimePoints, this.mValues, 0, i2 - 1);
|
|
|
|
int i3 = 1;
|
|
|
|
for (int i4 = 1; i4 < this.count; i4++) {
|
|
|
|
int[] iArr = this.mTimePoints;
|
|
|
|
if (iArr[i4 - 1] != iArr[i4]) {
|
|
|
|
i3++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
double[] dArr = new double[i3];
|
|
|
|
int[] iArr2 = new int[2];
|
|
|
|
iArr2[1] = 1;
|
|
|
|
iArr2[0] = i3;
|
|
|
|
double[][] dArr2 = (double[][]) Array.newInstance(double.class, iArr2);
|
|
|
|
int i5 = 0;
|
|
|
|
for (int i6 = 0; i6 < this.count; i6++) {
|
|
|
|
if (i6 > 0) {
|
|
|
|
int[] iArr3 = this.mTimePoints;
|
|
|
|
if (iArr3[i6] == iArr3[i6 - 1]) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dArr[i5] = ((double) this.mTimePoints[i6]) * 0.01d;
|
|
|
|
dArr2[i5][0] = (double) this.mValues[i6];
|
|
|
|
i5++;
|
|
|
|
}
|
|
|
|
this.mCurveFit = CurveFit.get(i, dArr, dArr2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
String str = this.mType;
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("##.##");
|
|
|
|
for (int i = 0; i < this.count; i++) {
|
2021-11-08 18:25:28 +00:00
|
|
|
StringBuilder V = a.V(str, "[");
|
|
|
|
V.append(this.mTimePoints[i]);
|
|
|
|
V.append(" , ");
|
|
|
|
V.append(decimalFormat.format((double) this.mValues[i]));
|
|
|
|
V.append("] ");
|
|
|
|
str = V.toString();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
}
|