2025-03-31 16:33:42 +02:00

244 lines
7.8 KiB
Java

package androidx.constraintlayout.motion.utils;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import androidx.constraintlayout.core.motion.utils.CurveFit;
import androidx.constraintlayout.core.motion.utils.SplineSet;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.constraintlayout.widget.ConstraintAttribute;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
public abstract class ViewSpline extends SplineSet {
private static final String TAG = "ViewSpline";
public abstract void setProperty(View view, float t);
public static ViewSpline makeCustomSpline(String str, SparseArray<ConstraintAttribute> attrList) {
return new CustomSet(str, attrList);
}
public static ViewSpline makeSpline(String str) {
str.hashCode();
switch (str) {
}
return new AlphaSet();
}
static class ElevationSet extends ViewSpline {
ElevationSet() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setElevation(get(t));
}
}
static class AlphaSet extends ViewSpline {
AlphaSet() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setAlpha(get(t));
}
}
static class RotationSet extends ViewSpline {
RotationSet() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setRotation(get(t));
}
}
static class RotationXset extends ViewSpline {
RotationXset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setRotationX(get(t));
}
}
static class RotationYset extends ViewSpline {
RotationYset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setRotationY(get(t));
}
}
static class PivotXset extends ViewSpline {
PivotXset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setPivotX(get(t));
}
}
static class PivotYset extends ViewSpline {
PivotYset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setPivotY(get(t));
}
}
public static class PathRotate extends ViewSpline {
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
}
public void setPathRotate(View view, float t, double dx, double dy) {
view.setRotation(get(t) + ((float) Math.toDegrees(Math.atan2(dy, dx))));
}
}
static class ScaleXset extends ViewSpline {
ScaleXset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setScaleX(get(t));
}
}
static class ScaleYset extends ViewSpline {
ScaleYset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setScaleY(get(t));
}
}
static class TranslationXset extends ViewSpline {
TranslationXset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setTranslationX(get(t));
}
}
static class TranslationYset extends ViewSpline {
TranslationYset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setTranslationY(get(t));
}
}
static class TranslationZset extends ViewSpline {
TranslationZset() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
view.setTranslationZ(get(t));
}
}
public static class CustomSet extends ViewSpline {
String mAttributeName;
SparseArray<ConstraintAttribute> mConstraintAttributeList;
float[] mTempValues;
public CustomSet(String attribute, SparseArray<ConstraintAttribute> attrList) {
this.mAttributeName = attribute.split(",")[1];
this.mConstraintAttributeList = attrList;
}
@Override // androidx.constraintlayout.core.motion.utils.SplineSet
public void setup(int curveType) {
int size = this.mConstraintAttributeList.size();
int numberOfInterpolatedValues = this.mConstraintAttributeList.valueAt(0).numberOfInterpolatedValues();
double[] dArr = new double[size];
this.mTempValues = new float[numberOfInterpolatedValues];
double[][] dArr2 = (double[][]) Array.newInstance((Class<?>) Double.TYPE, size, numberOfInterpolatedValues);
for (int i = 0; i < size; i++) {
int keyAt = this.mConstraintAttributeList.keyAt(i);
ConstraintAttribute valueAt = this.mConstraintAttributeList.valueAt(i);
dArr[i] = keyAt * 0.01d;
valueAt.getValuesToInterpolate(this.mTempValues);
int i2 = 0;
while (true) {
if (i2 < this.mTempValues.length) {
dArr2[i][i2] = r6[i2];
i2++;
}
}
}
this.mCurveFit = CurveFit.get(curveType, dArr, dArr2);
}
@Override // androidx.constraintlayout.core.motion.utils.SplineSet
public void setPoint(int position, float value) {
throw new RuntimeException("don't call for custom attribute call setPoint(pos, ConstraintAttribute)");
}
public void setPoint(int position, ConstraintAttribute value) {
this.mConstraintAttributeList.append(position, value);
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
this.mCurveFit.getPos(t, this.mTempValues);
CustomSupport.setInterpolatedValue(this.mConstraintAttributeList.valueAt(0), view, this.mTempValues);
}
}
static class ProgressSet extends ViewSpline {
boolean mNoMethod = false;
ProgressSet() {
}
@Override // androidx.constraintlayout.motion.utils.ViewSpline
public void setProperty(View view, float t) {
Method method;
if (view instanceof MotionLayout) {
((MotionLayout) view).setProgress(get(t));
return;
}
if (this.mNoMethod) {
return;
}
try {
method = view.getClass().getMethod("setProgress", Float.TYPE);
} catch (NoSuchMethodException unused) {
this.mNoMethod = true;
method = null;
}
if (method != null) {
try {
method.invoke(view, Float.valueOf(get(t)));
} catch (IllegalAccessException e) {
Log.e(ViewSpline.TAG, "unable to setProgress", e);
} catch (InvocationTargetException e2) {
Log.e(ViewSpline.TAG, "unable to setProgress", e2);
}
}
}
}
}