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

425 lines
16 KiB
Java

package androidx.constraintlayout.motion.widget;
import android.util.Log;
import android.view.View;
import androidx.constraintlayout.motion.utils.Easing;
import androidx.constraintlayout.motion.widget.SplineSet;
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
import androidx.constraintlayout.widget.ConstraintAttribute;
import androidx.constraintlayout.widget.ConstraintSet;
import com.discord.models.domain.ModelAuditLogEntry;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
public class MotionConstrainedPoint implements Comparable<MotionConstrainedPoint> {
public static final int CARTESIAN = 2;
public static final boolean DEBUG = false;
public static final int PERPENDICULAR = 1;
public static final String TAG = "MotionPaths";
public static String[] names = {ModelAuditLogEntry.CHANGE_KEY_POSITION, "x", "y", "width", "height", "pathRotate"};
private float alpha = 1.0f;
private boolean applyElevation = false;
public LinkedHashMap<String, ConstraintAttribute> attributes = new LinkedHashMap<>();
private float elevation = 0.0f;
private float height;
private int mDrawPath = 0;
private Easing mKeyFrameEasing;
public int mMode = 0;
private float mPathRotate = Float.NaN;
private float mPivotX = Float.NaN;
private float mPivotY = Float.NaN;
private float mProgress = Float.NaN;
public double[] mTempDelta = new double[18];
public double[] mTempValue = new double[18];
public int mVisibilityMode = 0;
private float position;
private float rotation = 0.0f;
private float rotationX = 0.0f;
public float rotationY = 0.0f;
private float scaleX = 1.0f;
private float scaleY = 1.0f;
private float translationX = 0.0f;
private float translationY = 0.0f;
private float translationZ = 0.0f;
public int visibility;
private float width;
/* renamed from: x reason: collision with root package name */
private float f16x;
/* renamed from: y reason: collision with root package name */
private float f17y;
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;
}
public void addValues(HashMap<String, SplineSet> hashMap, int i) {
for (String str : hashMap.keySet()) {
SplineSet splineSet = hashMap.get(str);
str.hashCode();
char c2 = 65535;
switch (str.hashCode()) {
case -1249320806:
if (str.equals(Key.ROTATION_X)) {
c2 = 0;
break;
}
break;
case -1249320805:
if (str.equals(Key.ROTATION_Y)) {
c2 = 1;
break;
}
break;
case -1225497657:
if (str.equals(Key.TRANSLATION_X)) {
c2 = 2;
break;
}
break;
case -1225497656:
if (str.equals(Key.TRANSLATION_Y)) {
c2 = 3;
break;
}
break;
case -1225497655:
if (str.equals(Key.TRANSLATION_Z)) {
c2 = 4;
break;
}
break;
case -1001078227:
if (str.equals("progress")) {
c2 = 5;
break;
}
break;
case -908189618:
if (str.equals(Key.SCALE_X)) {
c2 = 6;
break;
}
break;
case -908189617:
if (str.equals(Key.SCALE_Y)) {
c2 = 7;
break;
}
break;
case -760884510:
if (str.equals(Key.PIVOT_X)) {
c2 = '\b';
break;
}
break;
case -760884509:
if (str.equals(Key.PIVOT_Y)) {
c2 = '\t';
break;
}
break;
case -40300674:
if (str.equals(Key.ROTATION)) {
c2 = '\n';
break;
}
break;
case -4379043:
if (str.equals(Key.ELEVATION)) {
c2 = 11;
break;
}
break;
case 37232917:
if (str.equals(Key.TRANSITION_PATH_ROTATE)) {
c2 = '\f';
break;
}
break;
case 92909918:
if (str.equals(Key.ALPHA)) {
c2 = '\r';
break;
}
break;
}
float f = 1.0f;
float f2 = 0.0f;
switch (c2) {
case 0:
if (!Float.isNaN(this.rotationX)) {
f2 = this.rotationX;
}
splineSet.setPoint(i, f2);
break;
case 1:
if (!Float.isNaN(this.rotationY)) {
f2 = this.rotationY;
}
splineSet.setPoint(i, f2);
break;
case 2:
if (!Float.isNaN(this.translationX)) {
f2 = this.translationX;
}
splineSet.setPoint(i, f2);
break;
case 3:
if (!Float.isNaN(this.translationY)) {
f2 = this.translationY;
}
splineSet.setPoint(i, f2);
break;
case 4:
if (!Float.isNaN(this.translationZ)) {
f2 = this.translationZ;
}
splineSet.setPoint(i, f2);
break;
case 5:
if (!Float.isNaN(this.mProgress)) {
f2 = this.mProgress;
}
splineSet.setPoint(i, f2);
break;
case 6:
if (!Float.isNaN(this.scaleX)) {
f = this.scaleX;
}
splineSet.setPoint(i, f);
break;
case 7:
if (!Float.isNaN(this.scaleY)) {
f = this.scaleY;
}
splineSet.setPoint(i, f);
break;
case '\b':
if (!Float.isNaN(this.mPivotX)) {
f2 = this.mPivotX;
}
splineSet.setPoint(i, f2);
break;
case '\t':
if (!Float.isNaN(this.mPivotY)) {
f2 = this.mPivotY;
}
splineSet.setPoint(i, f2);
break;
case '\n':
if (!Float.isNaN(this.rotation)) {
f2 = this.rotation;
}
splineSet.setPoint(i, f2);
break;
case 11:
if (!Float.isNaN(this.elevation)) {
f2 = this.elevation;
}
splineSet.setPoint(i, f2);
break;
case '\f':
if (!Float.isNaN(this.mPathRotate)) {
f2 = this.mPathRotate;
}
splineSet.setPoint(i, f2);
break;
case '\r':
if (!Float.isNaN(this.alpha)) {
f = this.alpha;
}
splineSet.setPoint(i, f);
break;
default:
if (str.startsWith(Key.CUSTOM)) {
String str2 = str.split(",")[1];
if (this.attributes.containsKey(str2)) {
ConstraintAttribute constraintAttribute = this.attributes.get(str2);
if (splineSet instanceof SplineSet.CustomSet) {
((SplineSet.CustomSet) splineSet).setPoint(i, constraintAttribute);
break;
} else {
Log.e("MotionPaths", str + " splineSet not a CustomSet frame = " + i + ", value" + constraintAttribute.getValueToInterpolate() + splineSet);
break;
}
} else {
Log.e("MotionPaths", "UNKNOWN customName " + str2);
break;
}
} else {
Log.e("MotionPaths", "UNKNOWN spline " + str);
break;
}
}
}
}
public void applyParameters(View view) {
this.visibility = view.getVisibility();
this.alpha = view.getVisibility() != 0 ? 0.0f : view.getAlpha();
this.applyElevation = false;
this.elevation = view.getElevation();
this.rotation = view.getRotation();
this.rotationX = view.getRotationX();
this.rotationY = view.getRotationY();
this.scaleX = view.getScaleX();
this.scaleY = view.getScaleY();
this.mPivotX = view.getPivotX();
this.mPivotY = view.getPivotY();
this.translationX = view.getTranslationX();
this.translationY = view.getTranslationY();
this.translationZ = view.getTranslationZ();
}
public void applyParameters(ConstraintSet.Constraint constraint) {
ConstraintSet.PropertySet propertySet = constraint.propertySet;
int i = propertySet.mVisibilityMode;
this.mVisibilityMode = i;
int i2 = propertySet.visibility;
this.visibility = i2;
this.alpha = (i2 == 0 || i != 0) ? propertySet.alpha : 0.0f;
ConstraintSet.Transform transform = constraint.transform;
this.applyElevation = transform.applyElevation;
this.elevation = transform.elevation;
this.rotation = transform.rotation;
this.rotationX = transform.rotationX;
this.rotationY = transform.rotationY;
this.scaleX = transform.scaleX;
this.scaleY = transform.scaleY;
this.mPivotX = transform.transformPivotX;
this.mPivotY = transform.transformPivotY;
this.translationX = transform.translationX;
this.translationY = transform.translationY;
this.translationZ = transform.translationZ;
this.mKeyFrameEasing = Easing.getInterpolator(constraint.motion.mTransitionEasing);
ConstraintSet.Motion motion = constraint.motion;
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(MotionConstrainedPoint motionConstrainedPoint) {
return Float.compare(this.position, motionConstrainedPoint.position);
}
public void different(MotionConstrainedPoint motionConstrainedPoint, HashSet<String> hashSet) {
if (diff(this.alpha, motionConstrainedPoint.alpha)) {
hashSet.add(Key.ALPHA);
}
if (diff(this.elevation, motionConstrainedPoint.elevation)) {
hashSet.add(Key.ELEVATION);
}
int i = this.visibility;
int i2 = motionConstrainedPoint.visibility;
if (i != i2 && this.mVisibilityMode == 0 && (i == 0 || i2 == 0)) {
hashSet.add(Key.ALPHA);
}
if (diff(this.rotation, motionConstrainedPoint.rotation)) {
hashSet.add(Key.ROTATION);
}
if (!Float.isNaN(this.mPathRotate) || !Float.isNaN(motionConstrainedPoint.mPathRotate)) {
hashSet.add(Key.TRANSITION_PATH_ROTATE);
}
if (!Float.isNaN(this.mProgress) || !Float.isNaN(motionConstrainedPoint.mProgress)) {
hashSet.add("progress");
}
if (diff(this.rotationX, motionConstrainedPoint.rotationX)) {
hashSet.add(Key.ROTATION_X);
}
if (diff(this.rotationY, motionConstrainedPoint.rotationY)) {
hashSet.add(Key.ROTATION_Y);
}
if (diff(this.mPivotX, motionConstrainedPoint.mPivotX)) {
hashSet.add(Key.PIVOT_X);
}
if (diff(this.mPivotY, motionConstrainedPoint.mPivotY)) {
hashSet.add(Key.PIVOT_Y);
}
if (diff(this.scaleX, motionConstrainedPoint.scaleX)) {
hashSet.add(Key.SCALE_X);
}
if (diff(this.scaleY, motionConstrainedPoint.scaleY)) {
hashSet.add(Key.SCALE_Y);
}
if (diff(this.translationX, motionConstrainedPoint.translationX)) {
hashSet.add(Key.TRANSLATION_X);
}
if (diff(this.translationY, motionConstrainedPoint.translationY)) {
hashSet.add(Key.TRANSLATION_Y);
}
if (diff(this.translationZ, motionConstrainedPoint.translationZ)) {
hashSet.add(Key.TRANSLATION_Z);
}
}
public void different(MotionConstrainedPoint motionConstrainedPoint, boolean[] zArr, String[] strArr) {
zArr[0] = zArr[0] | diff(this.position, motionConstrainedPoint.position);
zArr[1] = zArr[1] | diff(this.f16x, motionConstrainedPoint.f16x);
zArr[2] = zArr[2] | diff(this.f17y, motionConstrainedPoint.f17y);
zArr[3] = zArr[3] | diff(this.width, motionConstrainedPoint.width);
zArr[4] = diff(this.height, motionConstrainedPoint.height) | zArr[4];
}
public void fillStandard(double[] dArr, int[] iArr) {
float[] fArr = {this.position, this.f16x, this.f17y, this.width, this.height, this.alpha, this.elevation, this.rotation, this.rotationX, this.rotationY, this.scaleX, this.scaleY, this.mPivotX, this.mPivotY, this.translationX, this.translationY, this.translationZ, this.mPathRotate};
int i = 0;
for (int i2 = 0; i2 < iArr.length; i2++) {
if (iArr[i2] < 18) {
dArr[i] = (double) fArr[iArr[i2]];
i++;
}
}
}
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 boolean hasCustomData(String str) {
return this.attributes.containsKey(str);
}
public void setBounds(float f, float f2, float f3, float f4) {
this.f16x = f;
this.f17y = f2;
this.width = f3;
this.height = f4;
}
public void setState(View view) {
setBounds(view.getX(), view.getY(), (float) view.getWidth(), (float) view.getHeight());
applyParameters(view);
}
public void setState(ConstraintWidget constraintWidget, ConstraintSet constraintSet, int i) {
setBounds((float) constraintWidget.getX(), (float) constraintWidget.getY(), (float) constraintWidget.getWidth(), (float) constraintWidget.getHeight());
applyParameters(constraintSet.getParameters(i));
}
}