mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-30 11:02:31 -06:00
608 lines
22 KiB
Java
608 lines
22 KiB
Java
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;
|
|
import androidx.core.app.NotificationCompat;
|
|
import io.sentry.protocol.ViewHierarchyNode;
|
|
import java.lang.reflect.Array;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.text.DecimalFormat;
|
|
import tech.rabbit.r1launcher.BuildConfig;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class TimeCycleSplineSet {
|
|
private static final int CURVE_OFFSET = 2;
|
|
private static final int CURVE_PERIOD = 1;
|
|
private static final int CURVE_VALUE = 0;
|
|
private static final String TAG = "SplineSet";
|
|
private static float VAL_2PI = 6.2831855f;
|
|
private int count;
|
|
long last_time;
|
|
protected CurveFit mCurveFit;
|
|
private String mType;
|
|
protected int mWaveShape = 0;
|
|
protected int[] mTimePoints = new int[10];
|
|
protected float[][] mValues = (float[][]) Array.newInstance((Class<?>) Float.TYPE, 10, 3);
|
|
private float[] mCache = new float[3];
|
|
protected boolean mContinue = false;
|
|
float last_cycle = Float.NaN;
|
|
|
|
public CurveFit getCurveFit() {
|
|
return this.mCurveFit;
|
|
}
|
|
|
|
public abstract boolean setProperty(View view, float f, long j, KeyCache keyCache);
|
|
|
|
protected void setStartTime(long j) {
|
|
this.last_time = j;
|
|
}
|
|
|
|
public void setType(String str) {
|
|
this.mType = str;
|
|
}
|
|
|
|
public String toString() {
|
|
String str = this.mType;
|
|
DecimalFormat decimalFormat = new DecimalFormat("##.##");
|
|
for (int i = 0; i < this.count; i++) {
|
|
str = str + "[" + this.mTimePoints[i] + " , " + decimalFormat.format(this.mValues[i]) + "] ";
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public float get(float f, long j, View view, KeyCache keyCache) {
|
|
this.mCurveFit.getPos(f, this.mCache);
|
|
float[] fArr = this.mCache;
|
|
float f2 = fArr[1];
|
|
if (f2 == 0.0f) {
|
|
this.mContinue = false;
|
|
return fArr[2];
|
|
}
|
|
if (Float.isNaN(this.last_cycle)) {
|
|
float floatValue = keyCache.getFloatValue(view, this.mType, 0);
|
|
this.last_cycle = floatValue;
|
|
if (Float.isNaN(floatValue)) {
|
|
this.last_cycle = 0.0f;
|
|
}
|
|
}
|
|
float f3 = (float) ((this.last_cycle + (((j - this.last_time) * 1.0E-9d) * f2)) % 1.0d);
|
|
this.last_cycle = f3;
|
|
keyCache.setFloatValue(view, this.mType, 0, f3);
|
|
this.last_time = j;
|
|
float f4 = this.mCache[0];
|
|
float calcWave = (calcWave(this.last_cycle) * f4) + this.mCache[2];
|
|
this.mContinue = (f4 == 0.0f && f2 == 0.0f) ? false : true;
|
|
return calcWave;
|
|
}
|
|
|
|
protected float calcWave(float f) {
|
|
switch (this.mWaveShape) {
|
|
case 1:
|
|
return Math.signum(f * VAL_2PI);
|
|
case 2:
|
|
return 1.0f - Math.abs(f);
|
|
case 3:
|
|
return (((f * 2.0f) + 1.0f) % 2.0f) - 1.0f;
|
|
case 4:
|
|
return 1.0f - (((f * 2.0f) + 1.0f) % 2.0f);
|
|
case 5:
|
|
return (float) Math.cos(f * VAL_2PI);
|
|
case 6:
|
|
float abs = 1.0f - Math.abs(((f * 4.0f) % 4.0f) - 2.0f);
|
|
return 1.0f - (abs * abs);
|
|
default:
|
|
return (float) Math.sin(f * VAL_2PI);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static TimeCycleSplineSet makeCustomSpline(String str, SparseArray<ConstraintAttribute> sparseArray) {
|
|
return new CustomSet(str, sparseArray);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* JADX WARN: Failed to find 'out' block for switch in B:39:0x00a2. Please report as an issue. */
|
|
public static TimeCycleSplineSet makeSpline(String str, long j) {
|
|
TimeCycleSplineSet rotationXset;
|
|
str.hashCode();
|
|
char c = 65535;
|
|
switch (str.hashCode()) {
|
|
case -1249320806:
|
|
if (str.equals("rotationX")) {
|
|
c = 0;
|
|
break;
|
|
}
|
|
break;
|
|
case -1249320805:
|
|
if (str.equals("rotationY")) {
|
|
c = 1;
|
|
break;
|
|
}
|
|
break;
|
|
case -1225497657:
|
|
if (str.equals("translationX")) {
|
|
c = 2;
|
|
break;
|
|
}
|
|
break;
|
|
case -1225497656:
|
|
if (str.equals("translationY")) {
|
|
c = 3;
|
|
break;
|
|
}
|
|
break;
|
|
case -1225497655:
|
|
if (str.equals("translationZ")) {
|
|
c = 4;
|
|
break;
|
|
}
|
|
break;
|
|
case -1001078227:
|
|
if (str.equals(NotificationCompat.CATEGORY_PROGRESS)) {
|
|
c = 5;
|
|
break;
|
|
}
|
|
break;
|
|
case -908189618:
|
|
if (str.equals("scaleX")) {
|
|
c = 6;
|
|
break;
|
|
}
|
|
break;
|
|
case -908189617:
|
|
if (str.equals("scaleY")) {
|
|
c = 7;
|
|
break;
|
|
}
|
|
break;
|
|
case -40300674:
|
|
if (str.equals("rotation")) {
|
|
c = '\b';
|
|
break;
|
|
}
|
|
break;
|
|
case -4379043:
|
|
if (str.equals("elevation")) {
|
|
c = '\t';
|
|
break;
|
|
}
|
|
break;
|
|
case 37232917:
|
|
if (str.equals("transitionPathRotate")) {
|
|
c = '\n';
|
|
break;
|
|
}
|
|
break;
|
|
case 92909918:
|
|
if (str.equals(ViewHierarchyNode.JsonKeys.ALPHA)) {
|
|
c = 11;
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
switch (c) {
|
|
case 0:
|
|
rotationXset = new RotationXset();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 1:
|
|
rotationXset = new RotationYset();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 2:
|
|
rotationXset = new TranslationXset();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 3:
|
|
rotationXset = new TranslationYset();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 4:
|
|
rotationXset = new TranslationZset();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 5:
|
|
rotationXset = new ProgressSet();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 6:
|
|
rotationXset = new ScaleXset();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 7:
|
|
rotationXset = new ScaleYset();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case '\b':
|
|
rotationXset = new RotationSet();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case '\t':
|
|
rotationXset = new ElevationSet();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case '\n':
|
|
rotationXset = new PathRotate();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
case 11:
|
|
rotationXset = new AlphaSet();
|
|
rotationXset.setStartTime(j);
|
|
return rotationXset;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void setPoint(int i, float f, float f2, int i2, float f3) {
|
|
int[] iArr = this.mTimePoints;
|
|
int i3 = this.count;
|
|
iArr[i3] = i;
|
|
float[] fArr = this.mValues[i3];
|
|
fArr[0] = f;
|
|
fArr[1] = f2;
|
|
fArr[2] = f3;
|
|
this.mWaveShape = Math.max(this.mWaveShape, i2);
|
|
this.count++;
|
|
}
|
|
|
|
public void setup(int i) {
|
|
int i2;
|
|
int i3 = this.count;
|
|
if (i3 == 0) {
|
|
Log.e(TAG, "Error no points added to " + this.mType);
|
|
return;
|
|
}
|
|
Sort.doubleQuickSort(this.mTimePoints, this.mValues, 0, i3 - 1);
|
|
int i4 = 1;
|
|
int i5 = 0;
|
|
while (true) {
|
|
int[] iArr = this.mTimePoints;
|
|
if (i4 >= iArr.length) {
|
|
break;
|
|
}
|
|
if (iArr[i4] != iArr[i4 - 1]) {
|
|
i5++;
|
|
}
|
|
i4++;
|
|
}
|
|
if (i5 == 0) {
|
|
i5 = 1;
|
|
}
|
|
double[] dArr = new double[i5];
|
|
double[][] dArr2 = (double[][]) Array.newInstance((Class<?>) Double.TYPE, i5, 3);
|
|
int i6 = 0;
|
|
for (0; i2 < this.count; i2 + 1) {
|
|
if (i2 > 0) {
|
|
int[] iArr2 = this.mTimePoints;
|
|
i2 = iArr2[i2] == iArr2[i2 - 1] ? i2 + 1 : 0;
|
|
}
|
|
dArr[i6] = this.mTimePoints[i2] * 0.01d;
|
|
double[] dArr3 = dArr2[i6];
|
|
float[] fArr = this.mValues[i2];
|
|
dArr3[0] = fArr[0];
|
|
dArr3[1] = fArr[1];
|
|
dArr3[2] = fArr[2];
|
|
i6++;
|
|
}
|
|
this.mCurveFit = CurveFit.get(i, dArr, dArr2);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class ElevationSet extends TimeCycleSplineSet {
|
|
ElevationSet() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setElevation(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class AlphaSet extends TimeCycleSplineSet {
|
|
AlphaSet() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setAlpha(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class RotationSet extends TimeCycleSplineSet {
|
|
RotationSet() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setRotation(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class RotationXset extends TimeCycleSplineSet {
|
|
RotationXset() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setRotationX(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class RotationYset extends TimeCycleSplineSet {
|
|
RotationYset() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setRotationY(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class PathRotate extends TimeCycleSplineSet {
|
|
PathRotate() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
return this.mContinue;
|
|
}
|
|
|
|
public boolean setPathRotate(View view, KeyCache keyCache, float f, long j, double d, double d2) {
|
|
view.setRotation(get(f, j, view, keyCache) + ((float) Math.toDegrees(Math.atan2(d2, d))));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class ScaleXset extends TimeCycleSplineSet {
|
|
ScaleXset() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setScaleX(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class ScaleYset extends TimeCycleSplineSet {
|
|
ScaleYset() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setScaleY(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class TranslationXset extends TimeCycleSplineSet {
|
|
TranslationXset() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setTranslationX(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class TranslationYset extends TimeCycleSplineSet {
|
|
TranslationYset() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setTranslationY(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class TranslationZset extends TimeCycleSplineSet {
|
|
TranslationZset() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
view.setTranslationZ(get(f, j, view, keyCache));
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class CustomSet extends TimeCycleSplineSet {
|
|
String mAttributeName;
|
|
float[] mCache;
|
|
SparseArray<ConstraintAttribute> mConstraintAttributeList;
|
|
float[] mTempValues;
|
|
SparseArray<float[]> mWaveProperties = new SparseArray<>();
|
|
|
|
public CustomSet(String str, SparseArray<ConstraintAttribute> sparseArray) {
|
|
this.mAttributeName = str.split(",")[1];
|
|
this.mConstraintAttributeList = sparseArray;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public void setup(int i) {
|
|
int size = this.mConstraintAttributeList.size();
|
|
int noOfInterpValues = this.mConstraintAttributeList.valueAt(0).noOfInterpValues();
|
|
double[] dArr = new double[size];
|
|
int i2 = noOfInterpValues + 2;
|
|
this.mTempValues = new float[i2];
|
|
this.mCache = new float[noOfInterpValues];
|
|
double[][] dArr2 = (double[][]) Array.newInstance((Class<?>) Double.TYPE, size, i2);
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
int keyAt = this.mConstraintAttributeList.keyAt(i3);
|
|
ConstraintAttribute valueAt = this.mConstraintAttributeList.valueAt(i3);
|
|
float[] valueAt2 = this.mWaveProperties.valueAt(i3);
|
|
dArr[i3] = keyAt * 0.01d;
|
|
valueAt.getValuesToInterpolate(this.mTempValues);
|
|
int i4 = 0;
|
|
while (true) {
|
|
if (i4 < this.mTempValues.length) {
|
|
dArr2[i3][i4] = r7[i4];
|
|
i4++;
|
|
}
|
|
}
|
|
double[] dArr3 = dArr2[i3];
|
|
dArr3[noOfInterpValues] = valueAt2[0];
|
|
dArr3[noOfInterpValues + 1] = valueAt2[1];
|
|
}
|
|
this.mCurveFit = CurveFit.get(i, dArr, dArr2);
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public void setPoint(int i, float f, float f2, int i2, float f3) {
|
|
throw new RuntimeException("don't call for custom attribute call setPoint(pos, ConstraintAttribute,...)");
|
|
}
|
|
|
|
public void setPoint(int i, ConstraintAttribute constraintAttribute, float f, int i2, float f2) {
|
|
this.mConstraintAttributeList.append(i, constraintAttribute);
|
|
this.mWaveProperties.append(i, new float[]{f, f2});
|
|
this.mWaveShape = Math.max(this.mWaveShape, i2);
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
this.mCurveFit.getPos(f, this.mTempValues);
|
|
float[] fArr = this.mTempValues;
|
|
float f2 = fArr[fArr.length - 2];
|
|
float f3 = fArr[fArr.length - 1];
|
|
this.last_cycle = (float) ((this.last_cycle + (((j - this.last_time) * 1.0E-9d) * f2)) % 1.0d);
|
|
this.last_time = j;
|
|
float calcWave = calcWave(this.last_cycle);
|
|
this.mContinue = false;
|
|
for (int i = 0; i < this.mCache.length; i++) {
|
|
this.mContinue |= ((double) this.mTempValues[i]) != BuildConfig.SENTRY_SAMPLE_RATE;
|
|
this.mCache[i] = (this.mTempValues[i] * calcWave) + f3;
|
|
}
|
|
this.mConstraintAttributeList.valueAt(0).setInterpolatedValue(view, this.mCache);
|
|
if (f2 != 0.0f) {
|
|
this.mContinue = true;
|
|
}
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public static class ProgressSet extends TimeCycleSplineSet {
|
|
boolean mNoMethod = false;
|
|
|
|
ProgressSet() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.TimeCycleSplineSet
|
|
public boolean setProperty(View view, float f, long j, KeyCache keyCache) {
|
|
Method method;
|
|
if (view instanceof MotionLayout) {
|
|
((MotionLayout) view).setProgress(get(f, j, view, keyCache));
|
|
} else {
|
|
if (this.mNoMethod) {
|
|
return false;
|
|
}
|
|
try {
|
|
method = view.getClass().getMethod("setProgress", Float.TYPE);
|
|
} catch (NoSuchMethodException unused) {
|
|
this.mNoMethod = true;
|
|
method = null;
|
|
}
|
|
Method method2 = method;
|
|
if (method2 != null) {
|
|
try {
|
|
method2.invoke(view, Float.valueOf(get(f, j, view, keyCache)));
|
|
} catch (IllegalAccessException e) {
|
|
Log.e(TimeCycleSplineSet.TAG, "unable to setProgress", e);
|
|
} catch (InvocationTargetException e2) {
|
|
Log.e(TimeCycleSplineSet.TAG, "unable to setProgress", e2);
|
|
}
|
|
}
|
|
}
|
|
return this.mContinue;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes.dex */
|
|
public static class Sort {
|
|
private Sort() {
|
|
}
|
|
|
|
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 = iArr2[i3 - 1];
|
|
int i5 = i3 - 2;
|
|
int i6 = iArr2[i5];
|
|
if (i4 < i6) {
|
|
int partition = partition(iArr, fArr, i4, i6);
|
|
iArr2[i5] = partition - 1;
|
|
iArr2[i3 - 1] = i4;
|
|
int i7 = i3 + 1;
|
|
iArr2[i3] = i6;
|
|
i3 += 2;
|
|
iArr2[i7] = partition + 1;
|
|
} else {
|
|
i3 = i5;
|
|
}
|
|
}
|
|
}
|
|
|
|
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[] fArr2 = fArr[i];
|
|
fArr[i] = fArr[i2];
|
|
fArr[i2] = fArr2;
|
|
}
|
|
}
|
|
}
|